-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (41 loc) · 1.2 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Deploy CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
deploy:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Install dependencies
run: npm ci
- name: Create .env file
run: |
echo "${{ secrets.secrets}}" > .env
- name: Sync code to application directory
run: |
rsync -avz --delete \
--exclude 'node_modules' \
--exclude '.git' \
--exclude '.gitignore' \
--exclude 'README.md' \
--exclude '.github' \
--exclude 'logs' \
./ /home/muhammedr7025/server
- name: Install dependencies in app directory
working-directory: /home/muhammedr7025/server
run: npm ci
- name: Install PM2 globally if not present
run: |
if ! command -v pm2 &> /dev/null; then
npm install pm2 -g
fi
- name: Restart PM2 process
working-directory: /home/muhammedr7025/server
run: pm2 restart ecosystem.config.js --env production