Check collaborator permissions for workflow_run events (#1590)

The write-permission gate previously only ran for issue/PR entity
events. Apply it to workflow_run events as well, checking both the
workflow actor and the actor recorded on the upstream run when they
differ. allowed_non_write_users and the github_token override behave
the same as for entity events. Document the behavior for workflow_run
pipelines.
This commit is contained in:
Ashwin Bhat
2026-08-04 10:05:34 -07:00
committed by GitHub
parent b80a0f042f
commit acb0385805
7 changed files with 233 additions and 9 deletions
+5 -2
View File
@@ -21,6 +21,7 @@ import {
isPullRequestEvent,
isPullRequestReviewEvent,
isPullRequestReviewCommentEvent,
isWorkflowRunEvent,
} from "../github/context";
import type { GitHubContext } from "../github/context";
import { detectMode } from "../modes/detector";
@@ -185,8 +186,10 @@ async function run() {
process.env.GITHUB_TOKEN = githubToken;
process.env.GH_TOKEN = githubToken;
// Check write permissions (only for entity contexts)
if (isEntityContext(context)) {
// Check write permissions for entity contexts, and for workflow_run
// events, whose upstream run may have been started by an actor without
// write access (e.g. the author of a fork pull request)
if (isEntityContext(context) || isWorkflowRunEvent(context)) {
const hasWritePermissions = await checkWritePermissions(
octokit.rest,
context,