fix: honor triggerType on refresh-token webhook deploys (#3710)#4627
Open
andikadevs wants to merge 1 commit into
Open
fix: honor triggerType on refresh-token webhook deploys (#3710)#4627andikadevs wants to merge 1 commit into
andikadevs wants to merge 1 commit into
Conversation
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.
f92e168 to
662ea75
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 respectstriggerType. 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:triggerType: "tag"app/compose still deployed on every branch push — the field was ignored (the exact bug reported, on Docker Compose).ref = refs/tags/x, whichextractBranchNameleaves unstripped) failed the branch match → tag pushes never deployed via this path.Change
extractTagNamehelper in[refreshToken].ts(detects tag events for GitHub/Gitea/GitLab/Bitbucket).sourceType === "github"branch of both handlers ontriggerType, mirroringgithub.tssemantics:Tag created: <tag>; ignore non-tag pushes.Scope is GitHub only, matching the issue and the original feature (PR #1613). No schema, migration, or UI changes — the
triggerTypecolumn and GitHub UI selector already exist.Checklist
canarybranch.Testing: added
extractTagNameunit tests in__test__/deploy/github.test.ts(40/40 pass) and verifiedbiome checkis clean on the touched files. Also exercised the handlers manually against a local instance with simulated branch-push vs tag-push payloads for bothtriggerTypesettings.Issues related (if applicable)
closes #3710