1
- name : Build and Deploy Nuxt Frontend
1
+ name : Build and Deploy Nuxt Frontend (SPA)
2
2
3
3
on :
4
4
push :
@@ -23,20 +23,25 @@ jobs:
23
23
run : |
24
24
cd frontend
25
25
npm install
26
- - name : Build Nuxt frontend
26
+
27
+ - name : Build Nuxt frontend (SPA)
27
28
run : |
28
29
cd frontend
29
30
npm run build
31
+
30
32
- name : List build directory (for debugging)
31
33
run : |
32
- ls -la frontend/.nuxt
34
+ ls -la frontend/.output
35
+
33
36
- name : Compress build artifacts
34
37
run : |
35
38
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
+
37
41
- name : List compressed file (for debugging)
38
42
run : |
39
43
ls -la frontend/nuxt-build.tar.gz
44
+
40
45
- name : Upload Nuxt build artifacts
41
46
uses : actions/upload-artifact@v3
42
47
with :
@@ -57,14 +62,15 @@ jobs:
57
62
name : nuxt-build
58
63
path : .
59
64
60
- - name : Deploy Nuxt frontend
65
+ - name : Deploy Nuxt frontend (SPA)
61
66
env :
62
67
SSH_PRIVATE_KEY : ${{ secrets.DEPLOY_KEY }}
63
68
SSH_PASSWORD : ${{ secrets.SSH_PASSWORD }}
64
69
run : |
65
70
echo "$SSH_PRIVATE_KEY" > deploy_key
66
71
chmod 600 deploy_key
67
72
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; }
68
74
ssh -o StrictHostKeyChecking=no -i deploy_key [email protected] '
69
75
export NVM_DIR="$HOME/.nvm" &&
70
76
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &&
76
82
rm /tmp/nuxt-build.tar.gz &&
77
83
cd /usr/share/nginx/html/ibminscut &&
78
84
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
80
87
' || { echo 'SSH command failed'; exit 1; }
81
88
rm deploy_key
0 commit comments