-
Notifications
You must be signed in to change notification settings - Fork 3
36 lines (30 loc) · 1.07 KB
/
deploy.yml
File metadata and controls
36 lines (30 loc) · 1.07 KB
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
name: 🚀 Auto Deploy to EC2
# develop 브랜치에 push 될 때마다 실행
on:
push:
branches:
- develop # ← 자동 배포를 트리거할 브랜치 이름
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup SSH key
uses: webfactory/ssh-agent@v0.9.1
with:
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
- name: Sync code to EC2
run: |
rsync -e "ssh -o StrictHostKeyChecking=no" -avz --delete \
--exclude='.git*' \
--exclude='node_modules' \
--exclude='.env' \
./ ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }}:${{ secrets.SERVER_PATH }}
- name: Build & Restart on EC2
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << 'EOF'
cd ${{ secrets.SERVER_PATH }}
npm install --production
pm2 restart UpAndDown-Server || pm2 start npm --name UpAndDown-Server -- run start
EOF