Skip to content

Commit 4205192

Browse files
Refactor CI/CD workflow with correct YAML format and improved PM2 steps
1 parent 0050aa3 commit 4205192

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

.github/workflows/nodejs.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,19 @@ jobs:
7171
key: ${{ secrets.SSH_PRIVATE_KEY }}
7272
port: 22
7373
script: |
74-
cd /usr/local/bin && pm2 restart test_server # <-- Use full path here!
74+
export PATH=$PATH:/usr/local/bin
75+
pm2 restart test_server
7576
76-
- name: Check PM2 logs
77+
- name: Check PM2 logs (safe and short)
7778
uses: appleboy/ssh-action@v1.0.0
7879
with:
7980
host: ${{ secrets.SERVER_IP }}
8081
username: ${{ secrets.SERVER_USER }}
8182
key: ${{ secrets.SSH_PRIVATE_KEY }}
8283
port: 22
8384
script: |
84-
cd /usr/local/bin && pm2 logs test_server # <-- Use full path here!
85+
export PATH=$PATH:/usr/local/bin
86+
pm2 logs test_server --lines 20 --nostream
8587
8688
- name: Check PM2 status
8789
uses: appleboy/ssh-action@v1.0.0
@@ -91,7 +93,8 @@ jobs:
9193
key: ${{ secrets.SSH_PRIVATE_KEY }}
9294
port: 22
9395
script: |
94-
cd /usr/local/bin && pm2 status test_server # <-- Use full path here!
96+
export PATH=$PATH:/usr/local/bin
97+
pm2 status test_server
9598
9699
- name: Check if the server is running
97100
uses: appleboy/ssh-action@v1.0.0
@@ -101,4 +104,4 @@ jobs:
101104
key: ${{ secrets.SSH_PRIVATE_KEY }}
102105
port: 22
103106
script: |
104-
curl -I http://localhost:3000
107+
curl -I http://localhost:3000 || exit 1

0 commit comments

Comments
 (0)