Skip to content

Commit 4802ad8

Browse files
committed
Switch PR evaluation to /evaluate comment trigger
Replace auto-trigger on prediction file changes with a manual /evaluate comment command. Only repo owners, members, and collaborators can trigger the workflow, preventing unnecessary CI runs on every PR update.
1 parent 4b60b1a commit 4802ad8

1 file changed

Lines changed: 55 additions & 11 deletions

File tree

.github/workflows/pr-evaluation.yml

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,61 @@
11
name: Router Submission Evaluation
22

33
on:
4-
pull_request_target:
5-
types: [opened, synchronize, reopened]
6-
paths:
7-
- "router_inference/predictions/**"
4+
issue_comment:
5+
types: [created]
86

97
jobs:
108
evaluate-router:
9+
if: >-
10+
github.event.issue.pull_request &&
11+
startsWith(github.event.comment.body, '/evaluate') &&
12+
(
13+
github.event.comment.author_association == 'OWNER' ||
14+
github.event.comment.author_association == 'MEMBER' ||
15+
github.event.comment.author_association == 'COLLABORATOR'
16+
)
1117
runs-on: self-hosted
1218
permissions:
1319
contents: read
1420
pull-requests: write
1521
steps:
22+
- name: Acknowledge /evaluate command
23+
uses: actions/github-script@v7
24+
with:
25+
script: |
26+
await github.rest.reactions.createForIssueComment({
27+
owner: context.repo.owner,
28+
repo: context.repo.repo,
29+
comment_id: context.payload.comment.id,
30+
content: 'eyes'
31+
});
32+
33+
- name: Fetch PR details
34+
id: pr
35+
uses: actions/github-script@v7
36+
with:
37+
script: |
38+
const pr = await github.rest.pulls.get({
39+
owner: context.repo.owner,
40+
repo: context.repo.repo,
41+
pull_number: context.payload.issue.number
42+
});
43+
core.setOutput('head_sha', pr.data.head.sha);
44+
core.setOutput('base_ref', pr.data.base.ref);
45+
core.setOutput('base_sha', pr.data.base.sha);
46+
core.setOutput('number', pr.data.number);
47+
1648
- name: Checkout base repository (for evaluation scripts)
1749
uses: actions/checkout@v4
1850
with:
19-
ref: ${{ github.event.pull_request.base.ref }}
51+
ref: ${{ steps.pr.outputs.base_ref }}
2052
path: base
2153
fetch-depth: 0
2254

2355
- name: Checkout PR branch (for prediction file only)
2456
uses: actions/checkout@v4
2557
with:
26-
ref: ${{ github.event.pull_request.head.sha }}
58+
ref: ${{ steps.pr.outputs.head_sha }}
2759
path: pr
2860
fetch-depth: 0
2961

@@ -35,8 +67,8 @@ jobs:
3567
set -euo pipefail
3668
# Compare against the upstream base branch
3769
# This ensures each router submission is evaluated independently
38-
BASE_REF="${{ github.event.pull_request.base.ref }}"
39-
BASE_SHA="${{ github.event.pull_request.base.sha }}"
70+
BASE_REF="${{ steps.pr.outputs.base_ref }}"
71+
BASE_SHA="${{ steps.pr.outputs.base_sha }}"
4072
4173
if [[ -z "$BASE_SHA" ]]; then
4274
echo "Error: Could not determine PR base SHA" >&2
@@ -158,9 +190,9 @@ jobs:
158190
run: |
159191
set -euo pipefail; trap 'cat evaluation_output.txt' EXIT
160192
# Uses base repo's evaluation script (safe - not from PR)
161-
BASE_SHA="${{ github.event.pull_request.base.sha }}"
193+
BASE_SHA="${{ steps.pr.outputs.base_sha }}"
162194
uv run python automation/process_pr_submission.py \
163-
--pr "${{ github.event.pull_request.number }}" \
195+
--pr "${{ steps.pr.outputs.number }}" \
164196
--router "${{ steps.detect.outputs.router }}" \
165197
--split "${{ steps.detect.outputs.split }}" \
166198
--base-ref "$BASE_SHA" > evaluation_output.txt 2>&1
@@ -213,9 +245,21 @@ jobs:
213245
214246
// Post comment to PR
215247
await github.rest.issues.createComment({
216-
issue_number: context.payload.pull_request.number,
248+
issue_number: context.payload.issue.number,
217249
owner: context.repo.owner,
218250
repo: context.repo.repo,
219251
body: comment
220252
});
221253
console.log('Successfully posted evaluation results as PR comment');
254+
255+
- name: React with success
256+
if: ${{ steps.detect.outputs.router != '' && steps.evaluate.outcome == 'success' }}
257+
uses: actions/github-script@v7
258+
with:
259+
script: |
260+
await github.rest.reactions.createForIssueComment({
261+
owner: context.repo.owner,
262+
repo: context.repo.repo,
263+
comment_id: context.payload.comment.id,
264+
content: 'rocket'
265+
});

0 commit comments

Comments
 (0)