feat: per-service tag filter for tag-triggered deployments - #4999
Open
elisiumm wants to merge 5 commits into
Open
feat: per-service tag filter for tag-triggered deployments#4999elisiumm wants to merge 5 commits into
elisiumm wants to merge 5 commits into
Conversation
Adds an optional tagFilter glob (micromatch) on application and compose, mirroring the existing watchPaths mechanism but for the tag deployment path. When set, a pushed tag only deploys services whose tagFilter matches the tag name; empty filter deploys on any tag (backward compatible). Solves the monorepo release-please case where a single tag (web-v*, api-v*, shared-v*) should only rebuild its own service.
Wires tagFilter through the GitHub provider forms (application and compose), shown only when triggerType is "tag" (mirrors the existing Watch Paths field shown for "push"), and through the saveGithubProvider router mutation. Compose picks it up automatically via its existing partial update schema. Adds a unit test suite for matchesTag and updates two existing test fixtures that construct a full Application object literal to account for the new column.
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
Adds an optional per-service Tag Filter for
triggerType: tag, so a pushed tag only deploys the services whose filter matches the tag name. Mirrors the existing Watch Paths feature (which filters branch pushes by changed path) — this filters tag pushes by tag name.Closes #4995
Why
With
triggerType: tag, a single pushed tag currently triggers every application/compose in the repo configured to deploy on tag — the tag name is never compared. For a monorepo where each service has its own tag prefix (common withrelease-please+node-workspace, which emits per-package tags likeweb-v0.7.1,api-v0.5.1,shared-v0.5.1), a frontend-only release still rebuilds and redeploys the backend, doubling deploy time and build-node resource use for nothing.Before this change, the tag path in
github.tsfinds alltriggerType = "tag"apps and enqueues a deployment for each, with no hook to scope by tag —tagNamewas only used for the deployment title.Changes (mirror of Watch Paths, opt-in, fully backward compatible)
application.ts,compose.ts): new nullabletagFiltertext column + drizzle-zod wiring. Empty/null = deploy on any tag (today's behavior).packages/server/src/utils/tag-filter/matches-tag.ts):matchesTag(tagFilter, tagName)usingmicromatch.isMatch— direct mirror ofshould-deploy.ts. Empty filter returnstrue.apps/dokploy/pages/api/deploy/github.ts): in the tag-event handler,continuepast any app/compose whosetagFilterdoesn't matchtagName, in both theapplicationsandcomposeloops. Push-branch path untouched.application.ts):saveGithubProvidernow persiststagFilter(compose'supdatealready forwards the full validated input).save-github-provider.tsx,save-github-provider-compose.tsx): a "Tag Filter" input shown only whentriggerType === "tag", reusing the existing form components, with a short tooltip: only deploy on tags matching this glob (e.g.web-*); leave empty to deploy on any tag. A brace expansion ({web-*,shared-*}) covers a service that must react to more than one prefix.0180_shocking_thena.sql(+ snapshot/journal), generated via the repo'sdrizzle-kit generate(schema diff only, no live DB needed).Example for a
release-pleasemonorepo:web-*api-*{api-*,shared-*}Testing
apps/dokploy/__test__/tag-filter/matches-tag.test.ts— empty filter deploys any tag, simple prefix glob, brace-expansion multi-prefix, non-matching tag rejected (4/4 pass).packages/serverandapps/dokploytypecheck: clean.biome check: clean on all touched files.Application-typed test fixtures (drop.test.ts,traefik.test.ts) gottagFilter: nulladded next to their existingwatchPaths: [], required by the fully-typed select type.Honest disclosure per CONTRIBUTING: I verified via unit test (
matchesTag), typecheck, Biome, and end-to-end code reading of the schema → router → webhook → UI path. I did not run the full local stack (Docker + Postgres + server:3000) for an interactive browser round-trip of the form persisting a value, nor a real GitHub tag-push payload against a seeded DB. Happy to add a screencast or further tests if maintainers prefer. One pre-existing repo-wide typecheck failure inapps/schedules(packages/server/src/templates/processors.ts) is unrelated to this change (zero diff on that file vscanary).Greptile Summary
The PR adds optional glob-based tag filters to application and compose GitHub tag deployments while preserving deploy-on-any-tag behavior for empty filters.
tagFilterfields and the corresponding database migration.Confidence Score: 4/5
The PR is not yet safe to merge because tag-filtered webhooks can report deployments that were never queued.
The previously reported response-count defect remains: filtering occurs inside both deployment loops, while the response count is still derived from the unfiltered application and compose query lengths.
Files Needing Attention: apps/dokploy/pages/api/deploy/github.ts
Reviews (4): Last reviewed commit: "test(webhooks): add matchesTag to @dokpl..." | Re-trigger Greptile
Context used (3)