Skip to content

Commit 00d1075

Browse files
committed
fix workflow
1 parent 76f84c9 commit 00d1075

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

.github/workflows/deploy-frontend.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Deploy Nuxt Frontend
1+
name: Build and Deploy Nuxt Frontend (SPA)
22

33
on:
44
push:
@@ -23,20 +23,25 @@ jobs:
2323
run: |
2424
cd frontend
2525
npm install
26-
- name: Build Nuxt frontend
26+
27+
- name: Build Nuxt frontend (SPA)
2728
run: |
2829
cd frontend
2930
npm run build
31+
3032
- name: List build directory (for debugging)
3133
run: |
32-
ls -la frontend/.nuxt
34+
ls -la frontend/.output
35+
3336
- name: Compress build artifacts
3437
run: |
3538
cd frontend
36-
tar -czf nuxt-build.tar.gz .nuxt static nuxt.config.js package.json
39+
tar -czf nuxt-build.tar.gz .output nuxt.config.ts package.json assets
40+
3741
- name: List compressed file (for debugging)
3842
run: |
3943
ls -la frontend/nuxt-build.tar.gz
44+
4045
- name: Upload Nuxt build artifacts
4146
uses: actions/upload-artifact@v3
4247
with:
@@ -57,14 +62,15 @@ jobs:
5762
name: nuxt-build
5863
path: .
5964

60-
- name: Deploy Nuxt frontend
65+
- name: Deploy Nuxt frontend (SPA)
6166
env:
6267
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
6368
SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }}
6469
run: |
6570
echo "$SSH_PRIVATE_KEY" > deploy_key
6671
chmod 600 deploy_key
6772
scp -o StrictHostKeyChecking=no -i deploy_key nuxt-build.tar.gz [email protected]:/tmp/nuxt-build.tar.gz || { echo 'SCP failed'; exit 1; }
73+
scp -o StrictHostKeyChecking=no -i deploy_key ecosystem.config.js [email protected]:/tmp/ecosystem.config.js || { echo 'SCP failed'; exit 1; }
6874
ssh -o StrictHostKeyChecking=no -i deploy_key [email protected] '
6975
export NVM_DIR="$HOME/.nvm" &&
7076
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&
@@ -76,6 +82,7 @@ jobs:
7682
rm /tmp/nuxt-build.tar.gz &&
7783
cd /usr/share/nginx/html/ibminscut &&
7884
echo "$SSH_PASSWORD" | sudo -S npm install --production &&
79-
pm2 restart nuxt-app || pm2 start npm --name "nuxt-app" -- run start
85+
echo "$SSH_PASSWORD" | sudo -S mv /tmp/ecosystem.config.js /usr/share/nginx/html/ibminscut/ecosystem.config.js &&
86+
echo "$SSH_PASSWORD" | sudo -S env "PATH=$PATH" pm2 start /usr/share/nginx/html/ibminscut/ecosystem.config.js
8087
' || { echo 'SSH command failed'; exit 1; }
8188
rm deploy_key

0 commit comments

Comments
 (0)