From aad98f092ca0d35a04f6d8bd2288382fa1da42a4 Mon Sep 17 00:00:00 2001 From: Anindra Date: Sat, 5 Dec 2026 02:28:20 +0530 Subject: [PATCH 1/3] fix(deploy): trigger Dokploy through the compose webhook The Cloudflare challenge in front of /api/compose.deploy answers a GitHub-hosted runner with 403 and a JS challenge page, so every tag left the Deploy workflow red. Use the per-compose webhook URL (DOKPLOY_WEBHOOK_URL) instead: that is the path GitHub's own deliveries already reach. --- .github/workflows/deploy.yml | 16 ++++++++++------ deploy/dokploy/README.md | 10 ++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3a654be..2cda954 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,19 +14,23 @@ jobs: name: Deploy the compose service runs-on: ubuntu-26.04 steps: + # The authenticated admin API (POST /api/compose.deploy) is behind Cloudflare's + # bot challenge, which answers GitHub-hosted runners with a 403 "Just a moment" + # page. The per-compose webhook is the integration path GitHub itself uses, so a + # token URL works where the API key does not. Store it as DOKPLOY_WEBHOOK_URL + # (Dokploy: Compose -> Deployments -> Webhook URL). - 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 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 }}"}') + -d '{"source":"github-actions","ref":"${{ github.ref_name }}"}') echo "Dokploy answered HTTP $status" head -c 500 /tmp/dokploy-response.json; echo test "$status" -ge 200 && test "$status" -lt 300 diff --git a/deploy/dokploy/README.md b/deploy/dokploy/README.md index 1b1a107..c6a5142 100644 --- a/deploy/dokploy/README.md +++ b/deploy/dokploy/README.md @@ -50,6 +50,16 @@ 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, while the webhook +path is the one GitHub's own deliveries use. If a challenge still appears, add a WAF skip +rule for the webhook path; do not disable Cloudflare 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 tagged 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 From faafbd725591e5b8410cae196396147924dadc82 Mon Sep 17 00:00:00 2001 From: Anindra Date: Sat, 5 Dec 2026 02:41:58 +0530 Subject: [PATCH 2/3] fix(deploy): identify CI calls to Dokploy with a stable user agent Cloudflare's bot challenge keys on curl's default UA; a named agent is easier to allow or skip narrowly if the rule is ever needed. --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2cda954..b9403d8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -30,6 +30,7 @@ jobs: status=$(curl -sS -o /tmp/dokploy-response.json -w '%{http_code}' \ -X POST "$DOKPLOY_WEBHOOK_URL" \ -H "Content-Type: application/json" \ + -A "path-deploy/1.0 (+https://github.com/an1ndra/path)" \ -d '{"source":"github-actions","ref":"${{ github.ref_name }}"}') echo "Dokploy answered HTTP $status" head -c 500 /tmp/dokploy-response.json; echo From 16dfff24bdbdfd0d699c4ef73aee61f7766486bb Mon Sep 17 00:00:00 2001 From: Anindra Date: Sat, 5 Dec 2026 02:45:52 +0530 Subject: [PATCH 3/3] fix(deploy): send Dokploy the push envelope its webhook expects Dokploy reads the branch only when X-GitHub-Event is present, and rejects a ref that is not the compose branch. A tag deploy therefore asks for refs/heads/main, where the tag commit lives. Verified: the webhook answers 200 and queues the compose deploy. --- .github/workflows/deploy.yml | 19 ++++++++++++++----- deploy/dokploy/README.md | 20 ++++++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b9403d8..159f49f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,11 +14,15 @@ jobs: name: Deploy the compose service runs-on: ubuntu-26.04 steps: - # The authenticated admin API (POST /api/compose.deploy) is behind Cloudflare's + # 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. The per-compose webhook is the integration path GitHub itself uses, so a - # token URL works where the API key does not. Store it as DOKPLOY_WEBHOOK_URL - # (Dokploy: Compose -> Deployments -> Webhook URL). + # 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 }} @@ -27,11 +31,16 @@ jobs: 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 '{"source":"github-actions","ref":"${{ github.ref_name }}"}') + -d "$payload") echo "Dokploy answered HTTP $status" head -c 500 /tmp/dokploy-response.json; echo test "$status" -ge 200 && test "$status" -lt 300 diff --git a/deploy/dokploy/README.md b/deploy/dokploy/README.md index c6a5142..11d2875 100644 --- a/deploy/dokploy/README.md +++ b/deploy/dokploy/README.md @@ -53,12 +53,20 @@ 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, while the webhook -path is the one GitHub's own deliveries use. If a challenge still appears, add a WAF skip -rule for the webhook path; do not disable Cloudflare 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 tagged source, so they converge on the -same code. +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