Skip to content

Commit cef2ab8

Browse files
Update Node.js CI/CD workflow with SSH deployment steps and PM2 management
1 parent 16ea13b commit cef2ab8

File tree

1 file changed

+51
-9
lines changed

1 file changed

+51
-9
lines changed

.github/workflows/nodejs.yml

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,76 @@ jobs:
2828
deploy:
2929
needs: build
3030
runs-on: ubuntu-latest
31+
3132
steps:
32-
- name: Deploy to Server 🌐
33+
- name: Install Node.js via nvm (if not installed)
3334
uses: appleboy/[email protected]
3435
with:
3536
host: ${{ secrets.SERVER_IP }}
3637
username: ${{ secrets.SERVER_USER }}
3738
key: ${{ secrets.SSH_PRIVATE_KEY }}
3839
port: 22
3940
script: |
40-
# Step 1: Install Node.js via nvm (if not installed)
4141
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
4242
sudo apt-get install -y nodejs
4343
44-
# Step 2: Navigate to project directory and pull the latest changes
44+
- name: Navigate to project directory and pull the latest changes
45+
uses: appleboy/[email protected]
46+
with:
47+
host: ${{ secrets.SERVER_IP }}
48+
username: ${{ secrets.SERVER_USER }}
49+
key: ${{ secrets.SSH_PRIVATE_KEY }}
50+
port: 22
51+
script: |
4552
cd ~/CI-CD-Integration-IN-NodeJS
4653
git pull origin master
4754
48-
# Step 3: Install dependencies with updated Node.js
55+
- name: Install dependencies with updated Node.js
56+
uses: appleboy/[email protected]
57+
with:
58+
host: ${{ secrets.SERVER_IP }}
59+
username: ${{ secrets.SERVER_USER }}
60+
key: ${{ secrets.SSH_PRIVATE_KEY }}
61+
port: 22
62+
script: |
4963
npm install
5064
51-
# Step 4: Restart the PM2 process
65+
- name: Restart the PM2 process
66+
uses: appleboy/[email protected]
67+
with:
68+
host: ${{ secrets.SERVER_IP }}
69+
username: ${{ secrets.SERVER_USER }}
70+
key: ${{ secrets.SSH_PRIVATE_KEY }}
71+
port: 22
72+
script: |
5273
pm2 restart test_server
5374
54-
# Step 5: Check PM2 logs
75+
- name: Check PM2 logs
76+
uses: appleboy/[email protected]
77+
with:
78+
host: ${{ secrets.SERVER_IP }}
79+
username: ${{ secrets.SERVER_USER }}
80+
key: ${{ secrets.SSH_PRIVATE_KEY }}
81+
port: 22
82+
script: |
5583
pm2 logs
5684
57-
# Step 6: Check PM2 status
85+
- name: Check PM2 status
86+
uses: appleboy/[email protected]
87+
with:
88+
host: ${{ secrets.SERVER_IP }}
89+
username: ${{ secrets.SERVER_USER }}
90+
key: ${{ secrets.SSH_PRIVATE_KEY }}
91+
port: 22
92+
script: |
5893
pm2 status
5994
60-
# Step 7: Check if the server is running
61-
curl -I http://localhost:3000
95+
- name: Check if the server is running
96+
uses: appleboy/[email protected]
97+
with:
98+
host: ${{ secrets.SERVER_IP }}
99+
username: ${{ secrets.SERVER_USER }}
100+
key: ${{ secrets.SSH_PRIVATE_KEY }}
101+
port: 22
102+
script: |
103+
curl -I http://localhost:3000

0 commit comments

Comments
 (0)