-
Notifications
You must be signed in to change notification settings - Fork 109
35 lines (30 loc) · 914 Bytes
/
deploy.yml
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
name: Deploy to EC2
on:
push:
branches: [main]
paths:
- "backend/**" # Only trigger on backend changes
- ".github/workflows/**"
jobs:
deploy:
runs-on: ubuntu-latest
# Add concurrency to prevent multiple deployments running at once
concurrency:
group: production
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd ~/gitdiagram
git fetch origin main
git reset --hard origin/main # Force local to match remote main
sudo chmod +x ./backend/nginx/setup_nginx.sh
sudo ./backend/nginx/setup_nginx.sh
chmod +x ./backend/deploy.sh
./backend/deploy.sh