Skip to content

Commit 5de35c7

Browse files
committed
Fix PR triage activation and skip prior assessments
1 parent 1a3b6a7 commit 5de35c7

4 files changed

Lines changed: 76 additions & 17 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
pr="repos/${GH_REPO}/issues/$1"
5+
labels=$(gh api "$pr" --jq '[.labels[].name] | any(. == "waiting-for-reply" or . == "invalid")')
6+
if [[ "$labels" == true ]]; then
7+
echo true
8+
exit 0
9+
fi
10+
11+
# The assessment stays on the PR even after a maintainer removes its label.
12+
gh api --paginate "$pr/comments?per_page=100" \
13+
--jq 'any(.[]; .user.login == "github-actions[bot]" and (.body | test("(?m)^### AI Assessment: (Invalid|Missing Details)\\s*$")))' \
14+
| jq -s 'any'

‎.github/workflows/pr-triage-dispatch.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
permissions:
99
actions: write
10+
contents: read
1011
pull-requests: read
1112

1213
concurrency:
@@ -21,6 +22,9 @@ jobs:
2122
MAX_RUNS_PER_DAY: 20
2223
MAX_ATTEMPTS_PER_PR: 2
2324
steps:
25+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
26+
with:
27+
persist-credentials: false
2428
- name: Start triage for pull requests from external contributors
2529
env:
2630
GH_TOKEN: ${{ github.token }}
@@ -88,6 +92,11 @@ jobs:
8892
echo "Reached the limit of ${MAX_RUNS_PER_DAY} triage runs per day."
8993
break
9094
fi
95+
already_triaged=$(bash .github/scripts/pr-already-triaged.sh "$number")
96+
if [ "$already_triaged" = true ]; then
97+
echo "Skipping already triaged #${number}"
98+
continue
99+
fi
91100
gh workflow run pr-triage.lock.yml -f pr_number="$number"
92101
echo "Started triage for #${number}"
93102
started=$((started + 1))

‎.github/workflows/pr-triage.lock.yml‎

Lines changed: 35 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.github/workflows/pr-triage.md‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,38 @@ jobs:
3232
check:
3333
runs-on: ubuntu-latest
3434
permissions:
35+
contents: read
3536
pull-requests: read
3637
outputs:
37-
result: ${{ steps.check.outputs.result }}
38+
result: ${{ steps.check.outputs.verdict }}
3839
failed_sections: ${{ steps.check.outputs.failed_sections }}
3940
steps:
41+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
42+
with:
43+
persist-credentials: false
44+
- name: Check for prior triage
45+
id: prior
46+
env:
47+
GH_TOKEN: ${{ github.token }}
48+
GH_REPO: ${{ github.repository }}
49+
PR_NUMBER: ${{ inputs.pr_number }}
50+
run: |
51+
already_triaged=$(bash .github/scripts/pr-already-triaged.sh "$PR_NUMBER")
52+
echo "already_triaged=$already_triaged" >> "$GITHUB_OUTPUT"
4053
- name: Check the pull request against the template
4154
id: check
55+
if: steps.prior.outputs.already_triaged == 'false'
4256
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
4357
with:
4458
script: |
4559
const prNumber = Number(context.payload.inputs.pr_number);
4660
const { data: pr } = await github.rest.pulls.get({ ...context.repo, pull_number: prNumber });
4761
if (pr.state !== 'open' || pr.draft) {
48-
core.setOutput('result', 'skip');
62+
core.setOutput('verdict', 'skip');
4963
return;
5064
}
5165
if (pr.changed_files === 0) {
52-
core.setOutput('result', 'invalid');
66+
core.setOutput('verdict', 'invalid');
5367
return;
5468
}
5569
@@ -122,7 +136,7 @@ jobs:
122136
if (!lint || !(checked(lint) || hasText(lint))) failed.push('Lint & tests');
123137
requireBox('Docs');
124138
125-
core.setOutput('result', failed.length > 0 ? 'missing_details' : 'pass');
139+
core.setOutput('verdict', failed.length > 0 ? 'missing_details' : 'pass');
126140
core.setOutput('failed_sections', failed.join(', '));
127141
128142
tools:
@@ -135,9 +149,6 @@ tools:
135149
max-ai-credits: 100
136150

137151
safe-outputs:
138-
# Previews outputs in the run summary without writing anything. Remove this
139-
# line once the previews look right.
140-
staged: true
141152
# Keep run diagnostics in the Actions logs instead of public tracking issues.
142153
report-failure-as-issue: false
143154
report-missing-tool:

0 commit comments

Comments
 (0)