@@ -24,15 +24,14 @@ Build and push your images:
2424cd app
2525docker compose build
2626docker compose push
27- cd ..
2827```
2928
3029## 📦 2. Copy to Server
3130
3231Copy your ` compose.yaml ` to the remote host:
3332
3433``` sh
35- scp app/ compose.yaml youruser@yourserver:
34+ scp compose.yaml youruser@yourserver:
3635```
3736
3837## 3. Set Secrets
@@ -59,7 +58,7 @@ Your backend is now live. 🚀
5958
6059## Upgrading
6160
62- To upgrade your app, simply increment the image tag versions in compose.yaml.
61+ To upgrade your app, simply increment the image tag versions in ` compose.yaml ` .
6362
6463The rest is the same:
6564
@@ -72,3 +71,67 @@ The rest is the same:
7271
7372If you want zero-downtime deployments, rollback support, or blue-green testing,
7473continue to [ Advanced Deployments] ( advanced.md ) .
74+
75+ ## ⚡ GitHub Actions
76+
77+ Here's a Github Actions workflow you can use to automate deployments.
78+
79+ ``` sh
80+ mkdir -p .github/workflows
81+ ```
82+
83+ <details >
84+ <summary >Show full workflow</summary >
85+
86+ ``` yaml title=".github/workflows/ci.yaml"
87+ name : Deploy
88+
89+ on :
90+ push :
91+ branches :
92+ - prod
93+
94+ jobs :
95+ deploy :
96+ runs-on : ubuntu-latest
97+ steps :
98+ - name : Checkout code
99+ uses : actions/checkout@v4
100+
101+ - name : Copy compose.yaml from repository to deployment dir
102+ uses : appleboy/scp-action@master
103+ with :
104+ host : ${{ secrets.VPS_HOST }}
105+ username : ${{ secrets.VPS_USER }}
106+ key : ${{ secrets.VPS_SSH_KEY }}
107+ source : " app/compose.yaml"
108+ target : " app/"
109+
110+ - name : Deploy with Docker Compose
111+ 112+ env :
113+ GHCR_PAT : ${{ secrets.GHCR_PAT }}
114+ with :
115+ host : ${{ secrets.VPS_HOST }}
116+ username : ${{ secrets.VPS_USER }}
117+ key : ${{ secrets.VPS_SSH_KEY }}
118+ envs : GHCR_PAT
119+ script : |
120+ set -euo pipefail
121+ cp .env app/
122+ cd app
123+
124+ # Pull images
125+ echo "$GHCR_PAT" | docker login ghcr.io --username "${{ github.actor }}" --password-stdin
126+ DOCKER_CLIENT_TIMEOUT=300 COMPOSE_HTTP_TIMEOUT=300 docker compose pull --quiet
127+
128+ # Bring up stack and run healthchecks
129+ trap 'docker compose down' ERR
130+ docker compose up -d
131+ docker compose exec -T caddy curl -fsS http://caddy:80/healthz
132+ # Add more healthchecks here
133+ # docker compose exec -T caddy curl -fsS http://api:8080/healthz
134+ # docker compose exec -T caddy curl -fsS http://postgrest:3000/
135+ ` ` `
136+
137+ </details>
0 commit comments