Skip to content

Add manual fork-PR CI dispatch to ci.yml - #402

Open
LukasAud wants to merge 4 commits into
mainfrom
add-manual-fork-ci-dispatch
Open

LukasAud wants to merge 4 commits into
mainfrom
add-manual-fork-ci-dispatch

Conversation

@LukasAud

@LukasAud LukasAud commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Fork PRs don't receive secrets (e.g. PUPPET_FORGE_TOKEN, CODECOV_TOKEN) via the normal pull_request trigger, so CI silently skips secret-dependent steps for external contributors.
  • Adds pr_number/ref inputs to the existing workflow_dispatch trigger, plus a resolve-ref job that resolves either into a ref (or empty string, meaning "no override, behave exactly as before").
  • Threads ref: ${{ needs.resolve-ref.outputs.ref }} into the spec job, which calls puppetlabs/cat-github-actions/.github/workflows/gem_ci.yml@main (already using @main, which has the ref input added in puppetlabs/cat-github-actions#191 — no pin bump needed).
  • Update: acceptance calls a repo-local reusable workflow (./.github/workflows/custom_acceptance.yml, kept around just to force acceptance tests under powershell.exe), not cat-github-actions' gem_acceptance.yml. It initially had no way to accept a ref override, which meant a manual dispatch with pr_number/ref would run spec against the right code but silently run acceptance against whatever ref triggered the dispatch instead — worse than not running, since it'd look like the PR's acceptance tests passed without ever testing its code. Added the same optional ref input/checkout override to custom_acceptance.yml and threaded it through from ci.yml, so both jobs now honor the resolved ref.

Test plan

  • Dispatch ci manually with ref set to a branch/SHA and confirm both spec and acceptance check out that ref
  • Dispatch ci manually with pr_number set to a fork PR and confirm both jobs run against refs/pull/<n>/merge with secrets available
  • Confirm normal push/pull_request runs on main are unaffected (ref input is empty, behaving exactly as before)

🤖 Generated with Claude Code

Fork PRs can't run CI jobs that need secrets via the normal
pull_request trigger. Add workflow_dispatch inputs and a resolve-ref
job that resolve a PR number or ref, threaded into the existing CI
jobs via cat-github-actions' gem_ci.yml/gem_acceptance.yml ref input
(puppetlabs/cat-github-actions#191).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@LukasAud
LukasAud requested a review from a team as a code owner October 21, 2026 14:30
acceptance called the repo-local custom_acceptance.yml, which had no
ref input, so a manual dispatch with pr_number/ref would silently run
acceptance against the wrong code while spec correctly tested the
resolved ref. Add the same optional ref input/checkout override used
in cat-github-actions' gem_ci.yml/gem_acceptance.yml, and thread it
through from ci.yml.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Mutable refs can cause secret-bearing jobs to execute different, potentially unreviewed revisions.

1 open issue
What changed in this PR

Adds manual CI dispatch for fork PRs or explicit refs, allowing secret-dependent tests to run against the selected code.

Changes:

  • Adds optional pr_number and ref dispatch inputs and a shared ref resolver.
  • Passes the resolved ref to both spec and acceptance jobs.
  • Adds an optional checkout override to the local PowerShell acceptance workflow.
File Description
.github/​workflows/​custom_acceptance.yml Accepts an optional ref and applies it during checkout.
.github/​workflows/​ci.yml Resolves manual dispatch inputs and passes the target to both test workflows.

Review effort: Balanced

Comment thread .github/workflows/ci.yml Outdated
refs/pull/<n>/merge is mutable: GitHub repoints it on every new push
to the PR, and spec/acceptance check it out independently, with
acceptance only starting after spec finishes. A fork author could
push a malicious commit in that window and have acceptance silently
execute it with PUPPET_FORGE_TOKEN in scope, instead of the commit a
maintainer actually reviewed before dispatching. Resolve pr_number/ref
to a concrete SHA once via the GitHub API (PR head SHA, matching the
module-track fork-PR precedent) and thread that everywhere instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

PR-number dispatches test the unmerged head instead of the promised merge result, leaving target-branch integration untested.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment thread .github/workflows/ci.yml Outdated
Pinning to .head.sha fixed the mutable-ref race but silently changed
what gets tested: the normal pull_request trigger (and this PR's own
test plan) tests the merge result via refs/pull/<n>/merge, not the
contributor's raw tip. A manual dispatch could pass while the PR
actually conflicts with the target branch. Resolve merge_commit_sha
instead (still immutable once captured), and fail explicitly if the
PR isn't mergeable yet or has conflicts, rather than silently testing
the wrong commit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@LukasAud
LukasAud requested a balanced review from Copilot October 22, 2026 14:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Executing fork-controlled code with repository secrets warrants maintainer security review and completion of the manual dispatch test plan.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants