File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments