Skip to content

feat(trigger-coolify-deploy): add cancel_native_only mode - #10

Merged
Andreas-Garcia merged 5 commits into
mainfrom
feat/coolify-cancel-native-only-draft-prs
Sep 2, 2026
Merged

Andreas-Garcia merged 5 commits into
mainfrom
feat/coolify-cancel-native-only-draft-prs

Conversation

@Andreas-Garcia

Copy link
Copy Markdown
Member

Summary

  • Adds a cancel_native_only input to trigger-coolify-deploy that, when set, force-stops any native (webhook-triggered) Coolify build for pr_number without triggering our own deploy.
  • Lets draft-PR CI stop Coolify's unmanaged native build from consuming the host's single build slot, while intentionally skipping an authoritative deploy for the draft.
  • Refactors the existing phantom-build cancel/force-stop logic into a shared 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 via python3 -c "yaml.safe_load(...)")
  • Consumed from the-music-deck-admin with cancel_native_only: true on a draft PR and confirmed the native build is stopped without our deploy job running
  • Existing non-draft preview/staging/prod deploy paths unaffected (default cancel_native_only: false)

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.
Copilot AI lite review requested due to automatic review settings September 2, 2026 09:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_only input that exits early after cancelling/force-stopping any queued/in-progress native (webhook-triggered) deployments for the given pr_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.
Copilot AI review requested due to automatic review settings September 2, 2026 10:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 disables set -e, but it currently doesn't check whether the curl/jq pipeline succeeded. If the API call or jq filter fails, phantoms becomes empty and the action will silently skip cancelling builds (this is especially risky for cancel_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.
Copilot AI review requested due to automatic review settings September 2, 2026 10:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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_uuid is 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.
Copilot AI review requested due to automatic review settings September 2, 2026 10:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment on lines +185 to +191
# 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.
Copilot AI review requested due to automatic review settings September 2, 2026 10:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@Andreas-Garcia
Andreas-Garcia merged commit bdf7929 into main Sep 2, 2026
1 check passed
@Andreas-Garcia
Andreas-Garcia deleted the feat/coolify-cancel-native-only-draft-prs branch September 2, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants