Skip to content

Commit 56109c0

Browse files
Create deploy.yml
Added CI/CD
1 parent 0e5aa38 commit 56109c0

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy to EC2
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
15+
- name: Copy files to EC2
16+
uses: appleboy/[email protected]
17+
with:
18+
host: ${{ secrets.EC2_HOST }}
19+
username: ${{ secrets.EC2_USER }}
20+
key: ${{ secrets.EC2_SSH_KEY }}
21+
source: "."
22+
target: "~/pradan_forms_processing_system_backend"
23+
24+
- name: SSH into EC2 and restart app
25+
uses: appleboy/[email protected]
26+
with:
27+
host: ${{ secrets.EC2_HOST }}
28+
username: ${{ secrets.EC2_USER }}
29+
key: ${{ secrets.EC2_SSH_KEY }}
30+
script: |
31+
cd ~/pradan_forms_processing_system_backend
32+
npm install --production
33+
pm2 restart myapp || pm2 start index.js --name "Pradan-app-backend"
34+
pm2 save

0 commit comments

Comments
 (0)