Skip to content

Publish bills on pull_request; GitHub now blocks pull_request_target - #248

Merged
DTrim99 merged 1 commit into
mainfrom
publish-bill-pull-request-trigger
Dec 4, 2026
Merged

DTrim99 merged 1 commit into
mainfrom
publish-bill-pull-request-trigger

Conversation

@DTrim99

@DTrim99 DTrim99 commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

"Publish Bill on PR Merge" can no longer start. GitHub now blocks pull_request_target by default in public repositories that have no Actions policy for it. Since 3 December, every run has ended in startup_failure with no jobs:

The next bill-review merge would not publish its bill. That includes #215 and the 2026 rehearsal bill that App v3 needs (p453).

What changes

The branch name still reaches the shell and Python only through env:, and it must match ^[a-z0-9][a-z0-9-]*$, as #241 set up. The PR number on a manual run must be digits.

The other option

An org admin could add an Actions policy that allows pull_request_target for .github/workflows/publish-bill.yml only. That would keep fork PRs publishing on merge. I can't see or change Actions policies (the API returns 403), and this PR works without one.

Tests

🤖 Generated with Claude Code

GitHub now blocks pull_request_target by default in public repositories
without an Actions policy for it, so every Publish Bill run ended in
startup_failure. The workflow runs on pull_request (closed, into main). A
fork PR's run has no secrets, so a fork job fails with the command to
publish by hand, and workflow_dispatch publishes a merged bill-review PR by
number after checking it through the API. Also drops the stale comment on
the removed migration 010 fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@PavelMakarchuk PavelMakarchuk 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.

Review at 346a7f7

This PR moves "Publish Bill on PR Merge" from pull_request_target to pull_request (closed, into main). GitHub now blocks pull_request_target by default in public repositories. A merged bill-review PR from a branch in this repository publishes as before. For a merged bill-review PR from a fork, a new fork job fails and prints the command to publish by hand. A new workflow_dispatch input publishes any merged bill-review PR by number. The PR also adds a read-only permissions block and removes the stale fallback comment from the #241 review.

Verdict: APPROVE

SUGGESTION

  1. .github/workflows/publish-bill.yml:44: two publish runs at the same time can deploy an older page set. modal_app.py runs scripts/prerender.mjs at deploy time, and it reads Supabase. Example: bill A merges, and bill B merges one minute later. Run A starts its deploy before run B writes published, but run A's deploy finishes last. The live pages then do not include bill B. This race existed before. The new manual input makes it more likely, because someone can publish several fork PRs one after the other. Fix: move the checkout and modal deploy steps into a second job (needs: publish) with concurrency: { group: publish-bill-deploy, cancel-in-progress: false }. Do not put the concurrency group on the publish job: GitHub keeps only one pending run per group, so a third run cancels the second run before it writes its Supabase row. A cancelled pending deploy is safe, because the newest deploy reads all published rows.
  2. .github/workflows/publish-bill.yml:88: the check reads line by line. printf '%s' "$REFORM_ID" | grep -Eq '^…$' passes when any one line matches. I ran the step with the branch bill/x + newline + y, and it passed and wrote two lines to $GITHUB_OUTPUT. Git does not allow control characters in ref names, so a real branch cannot do this. The comment at line 52 says the check makes the value a plain id, so a whole-string check is better. Fix: [[ "$REFORM_ID" =~ ^[a-z0-9][a-z0-9-]*$ ]].
  3. PR description: the fork count. The description says that 22 of the last 60 bill-review PRs came from a fork. gh pr list --label bill-review --state all -L 60 gives 33 cross-repository PRs: 17 merged, 3 closed and 13 open (#68, #70, #93, #111, #117, #128, #130, #132, #149, #150, #160, #163, #170). The 13 open ones will need the manual run if they merge as they are. Fix: correct the number, or push those branches into this repository before they merge.
  4. docs/APP_V3_BILL_CONTRACT.md:12–14: the contract says that the merge publishes the bill. For a fork PR, this is no longer true; someone must run the workflow by hand. Fix: add one sentence to the "Approved" row or to line 14, in this PR or in #249.

Security analysis

  • The claim about GitHub is correct. The GitHub changelog of 2 November 2026 ("pull_request_target blocked by default December 2") says that GitHub blocks pull_request_target events by default in public repositories, unless an Actions event policy allows them. Enforcement started on 2 December 2026. The run history agrees. The last tracker run that started was skipped on 2 December at 3:28pm EST. The five runs from 3 December, 4:11pm EST on, all ended in startup_failure. policyengine-api's pull_request_target workflow ended in startup_failure from 3 December, 4:41am EST on.
  • Secrets. GitHub passes no secrets (except a read-only GITHUB_TOKEN) to a pull_request run for a PR from a fork. A same-repository PR gets the secrets. So the fork job (line 33) and the head-repository check on publish (line 49) match what GitHub does. If the fork is deleted, head.repo is null, so the fork job runs and publish is skipped. That is correct.
  • Which code runs. For a merged PR, GITHUB_REF is refs/heads/main and GITHUB_SHA is the merge commit. So the workflow file that runs is the reviewed one on main. The publish step is inline, and the checkout at line 144 is ref: main. No step runs a script from the PR head.
  • New exposure. For a same-repository PR that closes without a merge, pull_request runs the PR's own copy of the workflow, with secrets. Both jobs skip, but an author could edit the conditions. Only a person with write access can push a branch here, and that person can already run any workflow with secrets through a push trigger. So this adds no new path to the secrets. Fork PRs get no secrets in any case.
  • Trigger and filters. types: [closed] and branches: [main] filter on the base branch. publish runs on a pull_request event only when merged == true, the bill-review label is present, and the head is in this repository. A manual run checks merged, base.ref == "main" and the label through the API. The PR number must be digits, and all PR values reach the shell through env:.
  • Permissions. contents: read and pull-requests: read are enough for actions/checkout and gh api …/pulls/N. The job writes only to Supabase and Modal, through secrets.
  • Double publish. A manual run for a PR that already published writes the same status, approved_at and review_pr_url again. That is safe.
  • Publish never runs. A label added after the merge, a fork PR, or a failed run each leave the bill in_review. The fork job makes the fork case visible, and the manual run fixes all three. A merge with no label shows only as skipped, as before.
  • Stale comment from the #241 review: fixed. Lines 107–108 now say "approved_at (the merge time) and the review PR". The text about the removed 010 fallback is gone.

What I checked

  • The full diff and the full workflow at 346a7f7. The YAML parses, and the jobs and permissions are as described. actionlint is not installed here, so I did not run it. The author reports it clean.
  • I extracted the "Read the review PR" step and ran it locally with read-only API calls. Manual runs: #219 gives hi-sb3125-hd1 and #171 (fork) gives id-sb1450, each with its merge time. #215 (open), #239 (no label), 1; echo pwned, an empty value and #99999 are refused (exit 1). Merge path: bill/ga-sb168 gives ga-sb168. bill/ga$(id), feature/x and bill/ are refused. The newline case is suggestion 2.
  • modal_app.py: the pre-render layer reads Supabase on each deploy (suggestion 1).
  • Sources: the GitHub changelog entry above; the GitHub Docs pages "Events that trigger workflows" (pull_request, workflow_dispatch) and "Securely using pull_request_target"; gh run list for this workflow and for policyengine-api.
  • No other workflow in this repository uses pull_request with secrets. The branch starts from fe43e9c and merges cleanly with main (53aaa7d). No CI checks run on this branch. The head was 346a7f7 at the start and at the end of this review.

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