Skip to content

fix: honor triggerType on refresh-token webhook deploys (#3710)#4627

Open
andikadevs wants to merge 1 commit into
Dokploy:canaryfrom
andikadevs:fix/deploy-on-tag-refresh-token-webhook
Open

fix: honor triggerType on refresh-token webhook deploys (#3710)#4627
andikadevs wants to merge 1 commit into
Dokploy:canaryfrom
andikadevs:fix/deploy-on-tag-refresh-token-webhook

Conversation

@andikadevs

@andikadevs andikadevs commented Jun 13, 2026

Copy link
Copy Markdown

What is this PR about?

Fixes #3710, where a project with Trigger Type = "On tag" still builds on every regular commit/push (and real tag pushes don't deploy).

The GitHub App webhook handler (pages/api/deploy/github.ts) already respects triggerType. But the refresh-token webhook handlers — the URL Dokploy shows for manual webhook setup — never looked at it:

  • apps/dokploy/pages/api/deploy/[refreshToken].ts (applications)
  • apps/dokploy/pages/api/deploy/compose/[refreshToken].ts (compose)

For a GitHub source they only checked watchPaths + branch match, so:

  1. A triggerType: "tag" app/compose still deployed on every branch push — the field was ignored (the exact bug reported, on Docker Compose).
  2. A real tag push (ref = refs/tags/x, which extractBranchName leaves unstripped) failed the branch match → tag pushes never deployed via this path.

Change

  • Add an exported extractTagName helper in [refreshToken].ts (detects tag events for GitHub/Gitea/GitLab/Bitbucket).
  • Gate the sourceType === "github" branch of both handlers on triggerType, mirroring github.ts semantics:
    • tag: deploy only on tag events (skip branch/watchPaths — tags aren't branch-scoped and the UI hides watchPaths for tags), titled Tag created: <tag>; ignore non-tag pushes.
    • push (default): ignore tag events; keep the existing branch + watchPaths checks unchanged.

Scope is GitHub only, matching the issue and the original feature (PR #1613). No schema, migration, or UI changes — the triggerType column and GitHub UI selector already exist.

Checklist

  • You created a dedicated branch based on the canary branch.
  • You have read the suggestions in the CONTRIBUTING.md file.
  • You have tested this PR in your local instance.

Testing: added extractTagName unit tests in __test__/deploy/github.test.ts (40/40 pass) and verified biome check is clean on the touched files. Also exercised the handlers manually against a local instance with simulated branch-push vs tag-push payloads for both triggerType settings.

Issues related (if applicable)

closes #3710

@andikadevs andikadevs requested a review from Siumauricio as a code owner June 13, 2026 03:15
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Jun 13, 2026
The GitHub App webhook handler (github.ts) already respects the
application/compose `triggerType` ("push" vs "tag"), but the
refresh-token webhook handlers did not look at it at all:

- apps/dokploy/pages/api/deploy/[refreshToken].ts
- apps/dokploy/pages/api/deploy/compose/[refreshToken].ts

For a GitHub source these handlers only checked watchPaths + branch
match. As a result a project configured with "On tag" still deployed on
every branch push (the field was ignored), and real tag pushes —
ref `refs/tags/x`, which extractBranchName leaves unstripped — failed
the branch match and never deployed.

Add an exported `extractTagName` helper and gate the `github` branch of
both handlers on `triggerType`, mirroring github.ts semantics:

- triggerType "tag": deploy only on tag events (skip branch/watchPaths,
  since tags are not branch-scoped and the UI hides watchPaths for tags),
  titled "Tag created: <tag>"; ignore non-tag pushes.
- triggerType "push" (default): ignore tag events; keep the existing
  branch + watchPaths checks unchanged.

Scope is GitHub only, matching the issue and the original feature
(PR Dokploy#1613). No schema, migration, or UI changes — the triggerType column
and GitHub UI selector already exist.

Adds unit tests for extractTagName across GitHub/Gitea/GitLab/Bitbucket.
@andikadevs andikadevs force-pushed the fix/deploy-on-tag-refresh-token-webhook branch from f92e168 to 662ea75 Compare June 13, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trigger type "On tag" seems ignored, builds triggered by commits/pushes

1 participant