feat(trigger-coolify-deploy): add cancel_native_only mode - #10
Conversation
Lets draft-PR workflows force-stop Coolify's native webhook-triggered preview build without triggering our own authoritative deploy, so draft PRs don't leave a phantom build consuming the host's single build slot while we intentionally skip deploying them.
There was a problem hiding this comment.
🟡 Changes recommended
The updated preflight check can now run in cancel_native_only mode but still emits a deploy-specific error message that should be reworded to match the new behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds a new “cancel native builds only” mode to the trigger-coolify-deploy composite action so draft-PR CI can stop Coolify’s unmanaged webhook-triggered preview builds from consuming the host’s single build slot, without triggering an authoritative deploy.
Changes:
- Adds a
cancel_native_onlyinput that exits early after cancelling/force-stopping any queued/in-progress native (webhook-triggered) deployments for the givenpr_number. - Refactors the existing native/phantom build cancellation logic into a shared
cancel_phantom_builds()bash function reused by both paths. - Updates the changelog to document the new input and required parameters.
File summaries
| File | Description |
|---|---|
CHANGELOG.md |
Documents the new cancel_native_only input behavior and requirements. |
.github/actions/trigger-coolify-deploy/action.yml |
Introduces cancel_native_only, adds early-exit path, and refactors phantom-build cancellation into a shared function. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| - name: Check required build-kill inputs | ||
| if: inputs.pr_number != '' | ||
| if: inputs.pr_number != '' || inputs.cancel_native_only == 'true' |
…e_only mode The preflight check now also runs when cancel_native_only is set, where no deploy is triggered — the old message referenced "PR-preview deploys" specifically, which no longer fit.
There was a problem hiding this comment.
🔵 Needs a closer look
The new shared cancellation function can silently no-op if the curl/jq query fails (especially problematic for cancel_native_only exiting 0), so it should warn or otherwise handle query failures explicitly.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
.github/actions/trigger-coolify-deploy/action.yml:174
cancel_phantom_builds()intentionally disablesset -e, but it currently doesn't check whether the curl/jq pipeline succeeded. If the API call or jq filter fails,phantomsbecomes empty and the action will silently skip cancelling builds (this is especially risky forcancel_native_only, which can exit 0 after doing nothing). Please capture the pipeline exit code and emit a warning (or fail fast) before proceeding.
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
…m-query failure cancel_phantom_builds() disables set -e around its curl|jq query but wasn't checking the pipeline's exit status, so a failed API call or jq parse error silently produced an empty result — worst case for cancel_native_only, which could then exit 0 having cancelled nothing.
There was a problem hiding this comment.
🔵 Needs a closer look
The new cancellation helper uses an unvalidated deployment_uuid in the cancel URL before validation, which should be tightened to avoid unexpected/path-manipulation behavior from malformed API data.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
.github/actions/trigger-coolify-deploy/action.yml:202
phantom_uuidis used to build the cancel URL before it’s validated. Since this value ultimately comes from an external API response, it should be validated (and ideally with a stricter UUID regex) before using it in the POST URL or SSH command to avoid path manipulation / unexpected behavior if Coolify returns a malformed value.
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
… in the cancel URL phantom_uuid comes straight from the Coolify API response and was only validated right before the SSH force-stop, after it had already been used unvalidated in the /cancel POST URL. Move the format check earlier so a malformed value from the API is rejected before it touches any URL or SSH command.
There was a problem hiding this comment.
🟡 Changes recommended
The newly added deployment UUID validation is too permissive and should be tightened to a canonical UUID shape before using the value in URL/SSH contexts.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
| # deployment_uuid comes from the Coolify API response — validate its shape | ||
| # before using it in a URL or SSH command, in case Coolify ever returns | ||
| # something malformed. | ||
| if ! printf '%s' "$phantom_uuid" | grep -qE '^[0-9a-f-]{36}$'; then | ||
| echo " WARNING: unexpected deployment_uuid format '${phantom_uuid}', skipping" | ||
| continue | ||
| fi |
…al UUID shape
The previous ^[0-9a-f-]{36}$ pattern accepted malformed strings (e.g. all
hyphens, or hyphens in arbitrary positions) as long as they were 36 chars
of hex digits and dashes. Use the canonical 8-4-4-4-12 form instead.
There was a problem hiding this comment.
🟢 Approval recommended
The new mode is properly gated/validated, reuses the same proven cancellation pathway, and the refactor preserves existing deploy behavior while cleanly adding an early-exit flow.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
Summary
cancel_native_onlyinput totrigger-coolify-deploythat, when set, force-stops any native (webhook-triggered) Coolify build forpr_numberwithout triggering our own deploy.cancel_phantom_builds()function reused by both the normal deploy path and the new early-exit path.Test plan
yamllint/YAML parse passes (verified locally viapython3 -c "yaml.safe_load(...)")the-music-deck-adminwithcancel_native_only: trueon a draft PR and confirmed the native build is stopped without our deploy job runningcancel_native_only: false)