-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (28 loc) · 871 Bytes
/
Copy pathcd.yml
File metadata and controls
36 lines (28 loc) · 871 Bytes
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: CD
on:
push:
branches: ["main"]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout (optional)
uses: actions/checkout@v4
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
port: ${{ secrets.DEPLOY_PORT || 22 }}
script: |
set -e
cd ${{ secrets.DEPLOY_PATH }}
# Get latest code
git fetch --all
git reset --hard origin/main
# Build + run prod stack
docker compose -f docker-compose.prod.yml pull || true
docker compose -f docker-compose.prod.yml up -d --build
# Optional: cleanup old images
docker image prune -f