ci: restrict Pi workflow trigger to repo admins #2

Merged
alex merged 1 commit from pi/restrict-trigger-to-admins into main 2026-07-01 09:26:29 +00:00

What

Restricts the Pi AI Agent workflow so that only repo admins can invoke it.

Why

Today the pi-agent job runs for any issue_comment starting with /pi , meaning any registered user on the forge could trigger the agent (and the LLM spend + repo write access that comes with it). The earlier bot-setup report (docs/setup-pi-bot.md) flagged this as a watch-out:

/pi currently triggers for any comment — consider restricting who can invoke it.

How

Adds an author_association guard to the job if:

if: |
  (startsWith(github.event.comment.body, '/pi ') || startsWith(github.event.review.body, '/pi '))
  && (github.event.comment.author_association == 'OWNER'
      || github.event.comment.author_association == 'MEMBER')
  • OWNER → repository owner (covers personal forges like this one)
  • MEMBER → org member with admin rights (covers org-owned repos)

Non-admin comments (CONTRIBUTOR, NONE, FIRST_TIME_CONTRIBUTOR, …) are now silently ignored by the job.

Scope

This forge currently has a single Pi workflow — .forgejo/workflows/pi.yml — so this one PR covers it.

Refs #1.

## What Restricts the Pi AI Agent workflow so that only **repo admins** can invoke it. ## Why Today the `pi-agent` job runs for **any** `issue_comment` starting with `/pi `, meaning any registered user on the forge could trigger the agent (and the LLM spend + repo write access that comes with it). The earlier bot-setup report ([`docs/setup-pi-bot.md`](../blob/main/docs/setup-pi-bot.md)) flagged this as a watch-out: > `/pi ` currently triggers for **any** comment — consider restricting who can invoke it. ## How Adds an `author_association` guard to the job `if`: ```yaml if: | (startsWith(github.event.comment.body, '/pi ') || startsWith(github.event.review.body, '/pi ')) && (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'MEMBER') ``` - `OWNER` → repository owner (covers personal forges like this one) - `MEMBER` → org member with admin rights (covers org-owned repos) Non-admin comments (`CONTRIBUTOR`, `NONE`, `FIRST_TIME_CONTRIBUTOR`, …) are now silently ignored by the job. ## Scope This forge currently has a single Pi workflow — `.forgejo/workflows/pi.yml` — so this one PR covers it. Refs #1.
Only users whose comment author_association is OWNER or MEMBER
(i.e. repo admins/owners) can now invoke /pi. Non-admin comments
are ignored by the job, closing the security gap where anyone could
trigger the agent.

Refs #1
alex merged commit 0f625268dc into main 2026-07-01 09:26:29 +00:00
alex deleted branch pi/restrict-trigger-to-admins 2026-07-01 09:26:29 +00:00
Sign in to join this conversation.
No reviewers
No labels
dependencies
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
alex/.profile!2
No description provided.