Skip to content

Commit e5da25d

Browse files
committed
[chore]: try to auto deploy
1 parent 3beb80b commit e5da25d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy FastAPI Backend
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches:
7+
- main
8+
- dev
9+
10+
jobs:
11+
deploy:
12+
name: Deploy to Server
13+
runs-on: ubuntu22.04
14+
15+
steps:
16+
- name: Checkout Code
17+
uses: actions/checkout@v3
18+
19+
- name: Setup SSH
20+
uses: webfactory/[email protected]
21+
with:
22+
ssh-private-key: ${{ secrets.SERVER_SSH_KEY }}
23+
24+
- name: Sync Code to Server
25+
run: |
26+
rsync -avz --delete \
27+
--exclude '.git' \
28+
--exclude '.github' \
29+
./ \
30+
${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:${{ secrets.REMOTE_PATH }}
31+
32+
- name: Build and Restart Docker on Server
33+
run: |
34+
ssh ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} << 'EOF'
35+
cd ${{ secrets.REMOTE_PATH }}
36+
cd ..
37+
docker-compose down
38+
docker-compose build
39+
docker-compose up -d
40+
EOF

0 commit comments

Comments
 (0)