Skip to content

Fix broken PR workflow around API diffs for fork PRs - #2291

Merged
Jevan Saks (jevansaks) merged 2 commits into
microsoft:mainfrom
jevansaks:user/jevansa/fork-pr-comment-gates
Aug 25, 2026
Merged

Fix broken PR workflow around API diffs for fork PRs#2291
Jevan Saks (jevansaks) merged 2 commits into
microsoft:mainfrom
jevansaks:user/jevansa/fork-pr-comment-gates

Conversation

@jevansaks

@jevansaks Jevan Saks (jevansaks) commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

  • Keep fork PR validation on the read-only pull_request security boundary.
  • Upload the generated API diff as a dedicated artifact.
  • Use a trusted workflow_run workflow to download that artifact and post or update the API-diff PR comment for both fork and same-repository contributions.

Why

Fork PR workflows receive a read-only GITHUB_TOKEN, even when the workflow requests pull-requests: write. The validation in #2290 completed successfully, then the no-diff comment step failed with 403 Resource not accessible by integration.

Granting the untrusted PR workflow write access would be unsafe. The split workflow follows GitHub's recommended pattern: untrusted code builds and uploads data with read-only permissions, while trusted workflow code on the default branch performs the privileged comment operation without checking out or executing contributor code.

The trusted workflow resolves the PR from the run's fork owner, branch, and exact head SHA because GitHub does not populate workflow_run.pull_requests for these fork runs.

Validation

The workflow_run job itself can only execute after this workflow definition exists on the default branch, which is the GitHub security boundary that gives the trusted follow-up workflow write permission.

Jevan Saks (jevansaks) and others added 2 commits August 24, 2026 18:46
Skip API diff comment steps for cross-repository pull requests, whose GITHUB_TOKEN is read-only, while preserving validation and artifact uploads.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c89a1dcf-0af3-4f7c-ad60-69a9866eeffd
Move PR comment publishing to a trusted workflow_run workflow that consumes the validation artifact without executing contributor code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c89a1dcf-0af3-4f7c-ad60-69a9866eeffd
@jevansaks Jevan Saks (jevansaks) changed the title ci: avoid fork PR comment failures ci: publish API diffs for fork PRs Aug 25, 2026
@jevansaks
Jevan Saks (jevansaks) marked this pull request as ready for review August 25, 2026 02:18
@jevansaks Jevan Saks (jevansaks) changed the title ci: publish API diffs for fork PRs Fix broken PR workflow around API diffs for fork PRs Aug 25, 2026
@jevansaks
Jevan Saks (jevansaks) enabled auto-merge (squash) August 25, 2026 02:20
@jevansaks
Jevan Saks (jevansaks) merged commit 45534f8 into microsoft:main Aug 25, 2026
5 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