Skip to content

Commit

Permalink
chore: update workflow (2core ecs cant run build)
Browse files Browse the repository at this point in the history
  • Loading branch information
ADKcodeXD committed Mar 10, 2024
1 parent 89339b0 commit b3b07e4
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions .github/workflows/depoly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,49 @@ on:
- master

jobs:
deploy:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Try Git Pull on Server
id: git-pull
uses: appleboy/ssh-action@master
- name: Setup Node.js
uses: actions/setup-node@v2
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /www/wwwroot/MMGC/MMGC-frontend
git pull || echo "Git pull failed, proceeding with SCP"
node-version: '18' # 使用你项目的Node.js版本

- name: Clear Remote Directory if Git Pull Fails
if: steps.git-pull.outcome == 'failure'
uses: appleboy/ssh-action@master
- name: Install Dependencies
run: npm install

- name: Build Project
run: npm run build

- name: Copy Build Artifacts to Server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
rm -rf /www/wwwroot/MMGC/MMGC-frontend/*
source: '.output/' # 确保这是你的build命令生成的文件夹
target: '/www/wwwroot/MMGC/MMGC-frontend'

- name: Copy Repository to Server if Git Pull Fails
if: steps.git-pull.outcome == 'failure'
uses: appleboy/scp-action@master
- name: Install Dependencies on Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: '.'
target: '/www/wwwroot/MMGC/MMGC-frontend'
script: |
cd /www/wwwroot/MMGC/MMGC-frontend
npm install # 如果服务器上需要安装依赖
- name: Install and Build on Server
- name: Start Application on Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /www/wwwroot/MMGC/MMGC-frontend
npm install
pm2 delete MMGCApp && npm run start:build
pm2 delete MMGCApp || true # 如果应用没有运行,忽略错误
npm run start

0 comments on commit b3b07e4

Please sign in to comment.