Skip to content

feat(ci): restrict to PR author as triggerman#195

Merged
louisliu2048 merged 7 commits intomainfrom
vui-chee/restrict-multi-jobs
Mar 16, 2026
Merged

feat(ci): restrict to PR author as triggerman#195
louisliu2048 merged 7 commits intomainfrom
vui-chee/restrict-multi-jobs

Conversation

@Vui-Chee
Copy link
Contributor

@Vui-Chee Vui-Chee commented Mar 13, 2026

Currently, some of our people love AI so much they trigger many actions simultaneously, but github actions can only handle at most 1 pending job request. As a result, some jobs will be dropped. Instead, we can add restrictions such as only the PR author can trigger the review and he/she can submit 1 job request at a time. AI can respond to many comments in 1 PR in 1 trigger instead of many.

This PR also prevents trigger when bot responds.

Restores the org-membership guard (OWNER/MEMBER/COLLABORATOR) that was
inadvertently dropped. Without it, any external GitHub user could trigger
Claude on their own fork PRs or issues, gaining access to ANTHROPIC_API_KEY
and contents:write in the base repo context.

Both conditions are now required: the actor must be a trusted org member
AND must be the PR/issue author (the original restriction this PR added).
With cancel-in-progress: true, any GitHub user posting a comment on a PR
(even non-@claude comments) would trigger a new workflow run in the same
concurrency group, immediately killing the in-progress Claude run before
the authorize job could even evaluate the new commenter.

Switching to false queues new runs instead, so legitimate Claude sessions
run to completion regardless of other comment activity.
Moving to workflow-level permissions escalated claude-review from
contents:read to contents:write and actions:read to actions:write.
The review job only reads repo contents; granting write access violates
least-privilege and widens the prompt-injection attack surface.

Restores explicit job-level permission blocks:
- authorize: no GITHUB_TOKEN scopes needed (pure shell logic)
- claude-review: contents:read, actions:read (read-only review path)

The workflow-level block continues to provide the write scopes needed
only by the claude (code-assist) job.
When Claude bot posts a comment or review in response to a trigger, the
event re-fires the workflow (issue_comment / pull_request_review_comment),
causing a second job where github.actor is 'claude[bot]' with
author_association: NONE, which fails authorization noisily.

Adding if: "!contains(github.actor, '[bot]')" to the authorize job makes
GitHub Actions skip it (and all downstream jobs that need it) for any bot
actor, silently no-oping the spurious second run.
@louisliu2048 louisliu2048 merged commit 0c31327 into main Mar 16, 2026
2 of 3 checks passed
Vui-Chee added a commit that referenced this pull request Mar 17, 2026
* main:
  fix(claude): dup comments @review and unwarranted auth step trigger (#202)
  feat(intercept): add bridge intercept in flashblocks (#177)
  add github token to claude step (#201)
  restore id-token (#200)
  fix: resolve Node compile issue, use nightly formatting, pin Rust to 1.93, and fix Claude 401s (#198)
  feat: integrate legacy migrate tool into bin/tools crate (#196)
  refactor(node): clean up main.rs (#187)
  feat(ci): restrict to PR author as triggerman (#195)
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