Skip to content

Commit 1c370cf

Browse files
ci: make public OCR reviews manual and hosted
Why: Public pull requests should not automatically schedule review work on a persistent self-hosted runner. Changed: - Run OCR on ubuntu-latest. - Accept only explicit review commands from authorized repository members. - Remove the pull_request_target path and unused event handling. Verification: - actionlint v1.7.7 - npm run agent:verify -- --profile spec-only --paths .github/workflows/ocr-review.yml Affected: - .github/workflows/ocr-review.yml Refs: - Public Actions runner hardening Session: - task-sessions/20260820-public-ocr-hosted-manual
1 parent 31f34a0 commit 1c370cf

1 file changed

Lines changed: 35 additions & 58 deletions

File tree

.github/workflows/ocr-review.yml

Lines changed: 35 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# OpenCodeReview PR auto-review — self-contained workflow for PUBLIC repos.
1+
# OpenCodeReview PR on-demand review — self-contained workflow for PUBLIC repos.
22
# GitHub only lets public caller repos invoke PUBLIC reusable workflows, so
33
# simulator-broker / agent-skills cannot call the private
44
# fiveonecode/workflows reusable. This file inlines the proven job body from
@@ -11,31 +11,23 @@ name: OpenCodeReview PR Review
1111
concurrency:
1212
group: >-
1313
${{
14-
(
15-
github.event_name == 'pull_request_target'
16-
|| (
17-
github.event_name == 'issue_comment'
18-
&& github.event.issue.pull_request
19-
&& github.event.comment.user.type != 'Bot'
20-
&& (
21-
github.event.comment.author_association == 'MEMBER'
22-
|| github.event.comment.author_association == 'OWNER'
23-
|| github.event.comment.author_association == 'COLLABORATOR'
24-
)
25-
&& (
26-
startsWith(github.event.comment.body, '/open-code-review')
27-
|| startsWith(github.event.comment.body, '@open-code-review')
28-
)
29-
)
14+
github.event.issue.pull_request
15+
&& github.event.comment.user.type != 'Bot'
16+
&& (
17+
github.event.comment.author_association == 'MEMBER'
18+
|| github.event.comment.author_association == 'OWNER'
19+
|| github.event.comment.author_association == 'COLLABORATOR'
3020
)
31-
&& format('ocr-{0}', github.event.pull_request.number || github.event.issue.number)
21+
&& (
22+
startsWith(github.event.comment.body, '/open-code-review')
23+
|| startsWith(github.event.comment.body, '@open-code-review')
24+
)
25+
&& format('ocr-{0}', github.event.issue.number)
3226
|| format('noop-{0}', github.run_id)
3327
}}
3428
cancel-in-progress: true
3529

3630
on:
37-
pull_request_target:
38-
types: [opened, synchronize, reopened]
3931
issue_comment:
4032
types: [created]
4133

@@ -46,52 +38,37 @@ permissions:
4638
jobs:
4739
code-review:
4840
if: |
49-
github.event_name == 'pull_request_target'
50-
|| (
51-
github.event_name == 'issue_comment'
52-
&& github.event.issue.pull_request
53-
&& github.event.comment.user.type != 'Bot'
54-
&& (
55-
github.event.comment.author_association == 'MEMBER'
56-
|| github.event.comment.author_association == 'OWNER'
57-
|| github.event.comment.author_association == 'COLLABORATOR'
58-
)
59-
&& (
60-
startsWith(github.event.comment.body, '/open-code-review')
61-
|| startsWith(github.event.comment.body, '@open-code-review')
62-
)
41+
github.event.issue.pull_request
42+
&& github.event.comment.user.type != 'Bot'
43+
&& (
44+
github.event.comment.author_association == 'MEMBER'
45+
|| github.event.comment.author_association == 'OWNER'
46+
|| github.event.comment.author_association == 'COLLABORATOR'
47+
)
48+
&& (
49+
startsWith(github.event.comment.body, '/open-code-review')
50+
|| startsWith(github.event.comment.body, '@open-code-review')
6351
)
64-
# Self-hosted; the org runner group is granted access to this public repo and
65-
# forking is restricted so untrusted forks cannot schedule workflow runs here.
66-
runs-on: self-hosted
52+
# Public-repository reviews run only after an authorized member requests one,
53+
# on GitHub's free, ephemeral standard runner.
54+
runs-on: ubuntu-latest
6755
timeout-minutes: 240
6856
steps:
6957
- name: Get PR context
7058
id: pr-context
7159
uses: actions/github-script@v7
7260
with:
7361
script: |
74-
let baseRef, headSha, title, prNumber;
75-
if (context.eventName === 'issue_comment') {
76-
prNumber = context.issue.number;
77-
const { data: pr } = await github.rest.pulls.get({
78-
owner: context.repo.owner,
79-
repo: context.repo.repo,
80-
pull_number: prNumber,
81-
});
82-
baseRef = pr.base.ref;
83-
headSha = pr.head.sha;
84-
title = pr.title;
85-
} else {
86-
prNumber = context.payload.pull_request.number;
87-
baseRef = context.payload.pull_request.base.ref;
88-
headSha = context.payload.pull_request.head.sha;
89-
title = context.payload.pull_request.title;
90-
}
62+
const prNumber = context.issue.number;
63+
const { data: pr } = await github.rest.pulls.get({
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
pull_number: prNumber,
67+
});
9168
core.setOutput('pr_number', String(prNumber));
92-
core.setOutput('base_ref', baseRef);
93-
core.setOutput('head_sha', headSha);
94-
core.setOutput('title', title);
69+
core.setOutput('base_ref', pr.base.ref);
70+
core.setOutput('head_sha', pr.head.sha);
71+
core.setOutput('title', pr.title);
9572
9673
- name: Checkout base (trusted)
9774
uses: actions/checkout@v4
@@ -195,4 +172,4 @@ jobs:
195172
stickySummary: true,
196173
incremental: true,
197174
incrementalOverlapThreshold: parseFloat(process.env.OCR_INCREMENTAL_OVERLAP_THRESHOLD),
198-
});
175+
});

0 commit comments

Comments
 (0)