Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,33 @@ jobs:
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_API_KEY: ${{ secrets.DOKPLOY_API_KEY }}
DOKPLOY_WEBHOOK_URL: ${{ secrets.DOKPLOY_WEBHOOK_URL }}
run: |
if [ -z "$DOKPLOY_API_KEY" ]; then
echo "::error::DOKPLOY_API_KEY is not set; cannot trigger the deployment."
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 "https://dokploy.hacksubset.com/api/compose.deploy" \
-H "x-api-key: $DOKPLOY_API_KEY" \
-X POST "$DOKPLOY_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{"composeId":"qFd9GlvcRtYr8iYIYNwhl","title":"GitHub tag ${{ github.ref_name }}"}')
-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
18 changes: 18 additions & 0 deletions deploy/dokploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ Pushes to `Develop`, pull requests and Dependabot branches therefore never touch
production; only a tag does. If a deploy should be skipped for a tag, disable auto-deploy
before pushing it.

The `Deploy` GitHub Actions workflow fires the per-compose **Webhook URL** (Compose →
Deployments), stored as the `DOKPLOY_WEBHOOK_URL` secret. It deliberately does not use
`POST /api/compose.deploy` with `DOKPLOY_API_KEY`: Cloudflare challenges that endpoint for
GitHub-hosted runner IPs and answers with a 403 "Just a moment" page. Two details make the
webhook work where the API does not:

- the request sends a named `User-Agent`; a bare `curl` agent is the thing the challenge
stops, so keep it if you edit the step;
- the body is a GitHub push envelope (`X-GitHub-Event: push`, `ref: refs/heads/main`,
`head_commit`). Dokploy only reads a branch when that header is present, and a tag ref
does not match the compose branch, so a tag deploy asks for `main` — where the tag commit
lives, and what the compose builds.

If Cloudflare ever starts challenging the named agent too, add a WAF skip rule for the
webhook path; do not disable protection for the whole dashboard hostname. The Dokploy git
integration and this workflow can both fire on the same tag, so a release may run two
builds; the compose builds from the same source, so they converge on the same code.

The compose builds from the tagged source (`build: context: ../..`) rather than pulling
`:latest`. That is deliberate: both webhooks fire at the same moment, so a `:latest` pull
would race the image build and could deploy the previous release. Building the tagged
Expand Down