服务端构建部署 #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 服务端构建部署 | |
on: workflow_dispatch | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./packages/server | |
steps: | |
- name: 获取代码 | |
uses: actions/checkout@v3 | |
- name: 安装 Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: 安装依赖 | |
run: npm install | |
- name: 构建 | |
run: npm run build | |
- name: 压缩 | |
run: tar -zcvf server.tar.gz dist package.json pm2.json | |
- name: 部署服务 | |
uses: AEnterprise/[email protected] | |
env: | |
DEPLOY_KEY: ${{ secrets.ACCESS_TOKEN }} | |
ARGS: -avz --delete --exclude='*.pyc' | |
SERVER_PORT: '22' | |
FOLDER: ./packages/server/server.tar.gz | |
SERVER_IP: ${{ secrets.SSH_HOST }} | |
USERNAME: ${{ secrets.SSH_USERNAME }} | |
SERVER_DESTINATION: /opt/nestjs-blog/deploy/ | |
- name: 重启服务 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.ACCESS_TOKEN }} | |
script: | | |
cd /opt/nestjs-blog/deploy | |
mkdir -p ./server | |
tar -xzvf server.tar.gz -C ./server | |
mkdir -p ../apps | |
mv -fn ./server ../apps/ | |
cd ../apps/server | |
npm install --omit=dev | |
npm run start:pm2 |