Skip to content

ci: post version suggestions via workflow_run instead of pull_request_target - #229

Merged
aesslinger merged 1 commit into
mainfrom
ci/version-suggestion-workflow-run
Dec 3, 2026
Merged

aesslinger merged 1 commit into
mainfrom
ci/version-suggestion-workflow-run

Conversation

@aesslinger

Copy link
Copy Markdown
Collaborator

Why

Every Version suggestion run since 2026-12-03 has ended in startup_failure. The run page explains why: "GitHub restricts pull_request_target on public repositories by default. To allow the event trigger, configure an Actions policy." GitHub turned this on for public repos on 2026-12-02. Allowing the trigger again needs a repo or org admin to add an Actions event policy. This PR removes the need for that trigger instead.

What

The job is split into two workflows, GitHub's recommended pattern for this case:

  • version-suggestion.yml now runs on pull_request with contents: read.
    • It keeps the same classify, baseline and next-version logic, unchanged.
    • It uploads the result as a one-day version-suggestion artifact (suggestion.json) instead of commenting.
    • Fork PRs only get a read-only token, which is all this job needs.
  • version-suggestion-comment.yml (new) runs on workflow_run when that workflow completes.
    • That trigger runs in the base repo with a writable token, also for fork PRs, and GitHub doesn't block it.
    • It never checks out or runs PR code.
    • It downloads the artifact and posts or minimizes the comment, using the same comment logic and marker as before.

A fork PR's run can influence the artifact, so the comment job checks it before posting anything:

  • every field must have the expected type and format: an integer PR number, a known class and channel, and semver-shaped baseline and suggested versions;
  • the PR is looked up through the API, and its head commit must equal the triggering run's head_sha, with base main.

Testing

  • actionlint is clean apart from two existing shellcheck style notes in the unchanged classify script, which are also present on main.
  • I ran the moved version math under node: rc.15 + patch/rc gives rc.16, rc.16 + stable gives 1.0.0, and 1.0.0 + minor/rc gives 1.1.0-rc.1.
  • The README is markdownlint clean.

Caveat: a workflow_run workflow only fires from the default branch. On this PR, the pull_request half runs and uploads the artifact, but the comment won't appear until after merge. The first PR opened after merging is the end-to-end test.

…_target

GitHub blocks pull_request_target by default on public repositories since
2026-12-02, so every Version suggestion run has been a startup_failure.
Split the job: version-suggestion.yml now runs on pull_request with a
read-only token, computes the suggestion and uploads it as an artifact;
the new version-suggestion-comment.yml runs on workflow_run, validates
the artifact and that its PR matches the run's head commit, and posts
the comment. Fork PRs keep working (#115) without an admin policy.

Co-Authored-By: Adam J Esslinger <esslinger@gmail.com>
@aesslinger aesslinger added the prerelease:rc Version suggestion targets a release candidate label Dec 3, 2026
@aesslinger aesslinger self-assigned this Dec 3, 2026
@aesslinger aesslinger added the github_actions Pull requests that update GitHub Actions code label Dec 3, 2026
@aesslinger
aesslinger merged commit 6353441 into main Dec 3, 2026
10 checks passed
@aesslinger
aesslinger deleted the ci/version-suggestion-workflow-run branch December 3, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code prerelease:rc Version suggestion targets a release candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant