Repository navigation
46 lines (43 loc) · 1.89 KB
/
Copy pathdeploy.yml
File metadata and controls
46 lines (43 loc) · 1.89 KB
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
37
38
39
40
41
42
43
44
45
46
name: Deploy
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: read
jobs:
dokploy:
name: Deploy the compose service
runs-on: ubuntu-26.04
steps:
# The authenticated admin API (POST /api/compose.deploy) sits behind Cloudflare's
# bot challenge, which answers GitHub-hosted runners with a 403 "Just a moment"
# page. Two things make the per-compose webhook work instead:
# - a named user agent, which the challenge does not stop (a bare curl is);
# - the GitHub push envelope. Dokploy's handler reads the branch only when an
# X-GitHub-Event header is present, and rejects a ref that is not the
# compose's branch (main), so a tag deploy asks for main — the tag commit is
# on main, and the compose builds the checked-out main.
# Store the URL as DOKPLOY_WEBHOOK_URL (Dokploy: Compose -> Deployments).
- name: Trigger Dokploy compose deploy
env:
DOKPLOY_WEBHOOK_URL: ${{ secrets.DOKPLOY_WEBHOOK_URL }}
run: |
if [ -z "$DOKPLOY_WEBHOOK_URL" ]; then
echo "::error::DOKPLOY_WEBHOOK_URL is not set; cannot trigger the deployment."
exit 1
fi
payload=$(jq -nc \
--arg sha "${{ github.sha }}" \
--arg message "Deploy ${{ github.ref_name }}" \
'{ref: "refs/heads/main", head_commit: {id: $sha, message: $message}, commits: []}')
status=$(curl -sS -o /tmp/dokploy-response.json -w '%{http_code}' \
-X POST "$DOKPLOY_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-H "X-GitHub-Event: push" \
-A "path-deploy/1.0 (+https://github.com/an1ndra/path)" \
-d "$payload")
echo "Dokploy answered HTTP $status"
head -c 500 /tmp/dokploy-response.json; echo
test "$status" -ge 200 && test "$status" -lt 300