Skip to content

Commit 87ecbfc

Browse files
authored
Merge pull request #2 from gikuser/feature/add-workflow-1
Add deploy workflow
2 parents 877ee9c + 5afe131 commit 87ecbfc

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy to Testing
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
workflow_dispatch: # Manual trigger button
8+
9+
jobs:
10+
build-test-deploy:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 20
21+
22+
- name: Install dependencies
23+
run: npm install
24+
25+
- name: Build React app
26+
run: npm run build-react
27+
28+
- name: Run Unit Tests
29+
run: npm test || true # Continue even if no tests
30+
31+
- name: Lint code
32+
run: npm run lint || echo "No lint configured"
33+
34+
- name: Deploy to Testing EC2
35+
uses: appleboy/ssh-action@v0.1.8
36+
with:
37+
host: ${{ secrets.TESTING_EC2_IP }}
38+
username: ubuntu
39+
key: ${{ secrets.EC2_SSH_KEY }}
40+
port: 22
41+
script: |
42+
cd ~/react-node-testing || git clone https://github.com/${{ github.repository }} ~/react-node-testing
43+
cd ~/react-node-testing
44+
git pull
45+
npm install
46+
npm run build-react
47+
pm2 restart react-node-app || pm2 start npm --name "react-node-app" -- start

0 commit comments

Comments
 (0)