File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy to EC2
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ deploy :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v4
15+
16+ - name : Setup SSH
17+ run : |
18+ mkdir -p ~/.ssh
19+ echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_rsa
20+ chmod 600 ~/.ssh/id_rsa
21+ ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts
22+
23+ - name : Deploy to EC2
24+ run : |
25+ ssh ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
26+ set -e
27+ cd ~/ssakssak-commit
28+
29+ echo "๐ฆ Pull latest code"
30+ git pull origin main
31+
32+ echo "๐ฆ Install dependencies"
33+ npm ci
34+
35+ echo "๐ Build Next.js"
36+ npm run build
37+
38+ echo "๐ Reload PM2 apps"
39+ pm2 reload next-app || pm2 start npm --name "next-app" -- run start -- --port 3000
40+ pm2 reload ssakssak-worker || pm2 start npm --name "ssakssak-worker" -- run worker:start
41+
42+ pm2 save
43+ EOF
You canโt perform that action at this time.
0 commit comments