Skip to content

Commit

Permalink
feat: add github actions yml
Browse files Browse the repository at this point in the history
  • Loading branch information
laoriy committed Dec 23, 2023
1 parent 831377a commit 2d82b3a
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Publish And Deploy Demo
on:
push:
branches:
- 'nuxt-realworld'

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:

# 下载源码
- name: Checkout
uses: actions/checkout@main

- name: Change Dir
run: cd 3.vue/5.server-render/nuxt-realworld

# 打包构建
- name: SetUp nodejs
uses: actions/setup-node@main


# 安装pnpm
- name: Install pnpm
run: npm install -g pnpm
# 安装依赖
- name: Build Dep
- run: pnpm install
- run: pnpm run build
- run: tar -zcvf release.tgz .output ecosystem.config.js

# 发布 Release
- name: Create Release
id: create_release
uses: actions/create-release@main
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

# 上传构建结果到 Release
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@main
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release.tgz
asset_name: release.tgz
asset_content_type: application/x-tgz

# 部署到服务器
- name: Deploy
uses: appleboy/ssh-action@main
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
cd /root/web/nuxt-realworld
wget https://github.com/laoriy/lagou-study/releases/latest/download/release.tgz -O release.tgz
tar zxvf release.tgz
pm2 reload

0 comments on commit 2d82b3a

Please sign in to comment.