Skip to content

Run the CLA check without pull_request_target - #5

Merged
bkeepers merged 6 commits into
masterfrom
claude/workflow-run-status
Nov 10, 2026
Merged

bkeepers merged 6 commits into
masterfrom
claude/workflow-run-status

Conversation

@bkeepers

@bkeepers bkeepers commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

GitHub now blocks pull_request_target by default in public repositories that have no Actions event policy, and setting one needs GitHub Team. The block becomes permanent on December 2, 2026. This lets the CLA check run without pull_request_target, from a workflow_run workflow.

With the new status-context input, the action reports its result as a commit status on the pull request's head commit instead of through its own job, which in a workflow_run or issue_comment workflow is attached to the default branch. The new head-sha input names the commit, normally github.event.workflow_run.head_sha. The action then lists open pull requests through the API and checks the one whose head is that commit. It reads nothing from the triggering run, so there is no artifact, PR number or branch name to trust. Signing by comment sets the status on the pull request's current head directly, without rerunning a workflow.

Without status-context the action behaves as before, so pull_request_target workflows keep working.

Consumer setup

docs/open-waters.md describes the pair of workflows:

  • CLA trigger runs on pull_request with no permissions or secrets and does nothing. Its completion is the signal. Its job must not be named cla.
  • On Dependabot's own runs the trigger job is named cla and passes, since Dependabot's runs may not get the App secret.
  • CLA runs on workflow_run when CLA trigger completes, except for Dependabot's runs, and on comments. It mints the App token as before, adds statuses: write, drops actions: write, and passes status-context: cla and head-sha.

The status is created with GITHUB_TOKEN, so its source is GitHub Actions, which is what water-levels' and aiscast's protect-main rulesets require for cla.

Races and shared heads

  • The commits query also returns the pull request's headRefOid. If it no longer matches the commit being checked, the action posts error on the old commit instead of a result for commits it did not read.
  • A status belongs to a commit, so when more than one open pull request has the same head the action posts error instead of one pull request's result. Closing the copy and pushing or commenting recheck clears it.
  • If the signatures file changes while a check runs, or its version cannot be read around an unsigned result, the check runs again after posting its result, in up to three passes, so a slow run's failure does not overwrite a signing run's success. Creating a missing .cla.json counts as a change, so the first check in a new repository ends with failure.
  • Comments on closed pull requests and on issues are ignored.

An unsigned result fails only the status, so the default branch's commit does not show a failed CLA job for every unsigned pull request. Errors, including a rejected signature write, post error and fail the job.

In status mode the PR opener is now loaded on comment runs too, so require-opener-as-author applies there as it does on pull request runs.

Tests

__tests__/integration/statusMode.test.ts covers lookup by head, pass and fail statuses, the opener check, stale and closed heads, shared heads on both paths, the head moving mid-check, a signature landing mid-check, a rejected signature write, signing by comment, and missing or misplaced inputs. The fake GitHub gained pull request listing, commit statuses and headRefOid. npm run lint, npm test and npm run build pass, and dist/ is rebuilt.

Known limitations

  • pull_request runs from some first-time contributors wait for a maintainer's approval, and GitHub runs no pull_request workflow while a pull request has merge conflicts. The CLA comment and status wait for those; a recheck comment runs the check without them.
  • A pull request that copies another's head shows that pull request's status until its own check runs.
  • pull_request runs use the pull request's own workflow files, so a pull request can add a job named cla that passes, and a required check sourced from GitHub Actions cannot tell it apart. This was already possible with pull_request_target. The docs describe how to close it by having the CLA App post the status; see Follow-ups.
  • Every run pages through all open pull requests to find the head. That is one request per 100 open pull requests.
  • Anyone who can open a pull request can copy another open pull request's head, which turns that pull request's cla status to error until a maintainer closes the copy.
  • Not yet verified end to end: workflow_run and issue_comment only run workflows on the default branch, so the first real run needs a consumer PR merged.

After merge

Follow-ups

  • Have the CLA App post the cla status, so a pull request's own job named cla cannot satisfy the required check. That needs the App's Commit statuses permission and a ruleset change in each repository, and no change to this action.
  • slackwater-ios closed-pr.yml also runs on pull_request_target.

Review

Three local rounds.

  • Round 1, Codex, Copilot, Claude Opus and Claude Sonnet: all four found that one result on a commit shared by several open pull requests let one pull request's result stand for another's, in both directions and on the comment path. Fixed by posting error for shared heads. Three found that a slow run could overwrite a signing run's success with a stale failure; fixed by checking again when the signatures file changed. Two found that status mode without head-sha passed silently; it now fails. Codex found that a pull request can add its own passing cla job; this predates the change and is documented above with a fix that needs settings changes. Also fixed: comments on closed pull requests, docs, changelog. Dismissed: the README's example column for head-sha is an example, not a default.
  • Round 2, Claude Opus and Sonnet: a retry ending in success left the job failed, and a rejected signature write showed as an unsigned failure with a green job. Both fixed with tests. Dismissed: a signing run's own write triggers one extra pass, which is bounded and harmless.
  • Round 3, Claude Opus and Sonnet: no code defects. Doc claims about closing a copied head, reopening old pull requests and the retry guarantee were corrected; copied heads and merge conflicts were added to the limitations; head-sha without status-context is now rejected. The missing-file error and the per-run listing cost are listed as limitations.

The reviews were static. Tests, lint and build ran after each round's fixes; no model review ran after the round 3 doc and input fixes.

After the PR opened, Copilot found that a failed pull request lookup left the required status pending and that two unreadable version reads looked unchanged. Both are fixed with tests. A fourth Claude Opus and Sonnet round on that fix found no defects; its low findings led to separating a missing signatures file from an unreadable one, so a broken file no longer repeats error three times, and to keeping the lookup error when posting its status fails. Tests, lint and build ran after those changes; no model review ran after them.

GitHub blocks pull_request_target by default in public repositories
without an Actions event policy. The status-context and head-sha inputs
let a workflow_run workflow, triggered by a secret-free pull_request
workflow, check the open pull request whose head is the triggering
commit and report a commit status on it. Signing by comment updates the
status directly instead of rerunning a workflow. Without status-context
the action behaves as before.
…mode

A status belongs to the commit, so pull requests that share a head get
an error status instead of one pull request's result. A check that
overlaps a signature write runs again, so a stale failure does not
outlast the signing run's success. An unsigned result fails only the
status; errors, including a rejected signature write, set an error
status and fail the job. Comments on closed pull requests are ignored,
and head-sha is required with status-context outside issue_comment.
Copilot AI lite review requested due to automatic review settings November 9, 2026 18:18

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

Two moderate active issues remain in status-mode error handling: pull-request lookup failures can leave the required status pending, and unreadable content versions can allow a stale failure to be posted without retrying or failing closed.

2 open issues
What changed in this PR

This PR adds an optional commit-status mode for CLA checks, allowing them to run from workflow_run and issue_comment workflows without relying on pull_request_target, while preserving existing behavior when the new inputs are unused.

Changes:

  • Added status-context and head-sha inputs with pull-request lookup by head commit and commit-status reporting.
  • Added shared-head detection, head-movement checks, and bounded retries for signature changes.
  • Updated source, documentation, tests, fake GitHub helpers, changelog, and the bundled action.
  • Review findings include three moderate issues in src/statusMode.ts and one documentation nit in docs/open-waters.md.
File Summary
src/​statusMode.ts Implements status-mode pull-request lookup, validation, status reporting, retries, and comment-event support.
src/​shared/​getInputs.ts Reads the new status-mode inputs.
src/​setupClaCheck.ts Returns check results and adapts signing, rerun, and error handling for status mode.
src/​main.ts Validates inputs and dispatches status-mode execution.
src/​graphql.ts Verifies the pull-request head while collecting commit authors.
README.md Documents status-mode usage and inputs.
docs/​open-waters.md Describes the replacement workflow architecture, setup, and limitations.
dist/​index.js Rebuilt bundled action implementation.
CHANGELOG.md Records the new status-mode functionality.
action.yml Declares and documents the new action inputs.
__tests__/​testHelpers/​fakeGithubCore.ts Adds fake pull-request listing, head metadata, and commit-status support.
__tests__/​testHelpers/​context.ts Keeps test issue context synchronized with dynamically loaded pull requests.
__tests__/​main.test.ts Adjusts input mocks for the new status-mode inputs.
__tests__/​integration/​statusMode.test.ts Covers lookup, status outcomes, races, signing, errors, and edge cases.

Review effort: Lite

Comment thread src/statusMode.ts Resolved
Comment thread src/statusMode.ts Resolved
…versions

A failed pull request lookup now posts an error status on the
requested head instead of leaving the required status pending. An
unreadable signatures file version counts as changed, so two failed
reads cannot settle a stale failure.

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

Approval should wait for documented consumer-repository end-to-end validation of the new privileged event path, including fork-head status creation, token permissions, and required-check ruleset behavior.

No open issues 🎉

2 resolved since last review

Review effort: Lite

A missing signatures file counts as a version of its own, so creating it
triggers one more pass that reports the unsigned result. A file that
cannot be read ends the run after an error instead of repeating it.
A failure to post the lookup-error status no longer hides the lookup
error.
@bkeepers
bkeepers merged commit f07dfd3 into master Nov 10, 2026
4 checks passed
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