Skip to content

Commit c0ccde3

Browse files
committed
CI: add deployment pipeline
1 parent 890da86 commit c0ccde3

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.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 to VPS
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
name: Deploy via SSH
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v4
16+
17+
- name: Deploy to VPS
18+
uses: appleboy/ssh-action@v1.0.3
19+
with:
20+
host: ${{ secrets.VPS_HOST }}
21+
username: ${{ secrets.VPS_USER }}
22+
key: ${{ secrets.VPS_SSH_KEY }}
23+
port: ${{ secrets.VPS_PORT }}
24+
script: |
25+
echo ">>> Navigating to project directory"
26+
cd ${{ secrets.VPS_PROJECT_PATH }}
27+
28+
echo ">>> Pulling latest changes from main"
29+
git pull origin main
30+
31+
echo ">>> Stopping running containers"
32+
docker compose down
33+
34+
echo ">>> Rebuilding and starting containers"
35+
docker compose up -d --build
36+
37+
echo ">>> Cleaning up unused Docker resources"
38+
docker image prune -f
39+
40+
echo ">>> Deployment complete!"

0 commit comments

Comments
 (0)