Skip to content

Commit 639b370

Browse files
ci(risk): Move the PR risk check to the classifiers action (#6677)
* ci(risk): Move the PR risk check to the classifiers action The risk classifier moved from getsentry/sdk-pr-risk-action to the internal getsentry/classifiers repository. A public repository cannot call an action in an internal one directly, so the workflow now gets a short-lived, read-only app token, checks the classifiers out at a pinned commit and runs the action from that checkout. Classification is unchanged. Two things are new: the action skips runs started by a title or description edit when the PR already has a risk label, and it keeps one summary comment on the PR with the label and its reasons. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * ci(risk): Identify the classifiers app by its client ID The token action deprecates app-id in favour of client-id. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
1 parent 6d31f3a commit 639b370

2 files changed

Lines changed: 71 additions & 46 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: PR classifiers
2+
3+
on:
4+
pull_request_target:
5+
# Keep `edited`: it is the only event fired when the base branch changes. The action
6+
# itself skips title and description edits.
7+
types: [opened, synchronize, reopened, ready_for_review, edited, converted_to_draft]
8+
9+
permissions: {}
10+
11+
concurrency:
12+
# Two groups per pull request. Runs started by a title or description edit ("text") must
13+
# never share a group with the runs that score a revision ("score"): GitHub keeps only one
14+
# pending run per group, so a pending text edit would replace the pending run for a new
15+
# commit, and the action would then skip the edit because the previous commit's label is
16+
# still on the PR. Do not simplify this expression.
17+
group: pr-classifiers-${{ github.event.pull_request.number }}-${{ github.event.action == 'edited' && !github.event.changes.base && 'text' || 'score' }}
18+
# Every started run must reach its label clear; an overtaken run ends as `pr_changed`.
19+
cancel-in-progress: false
20+
21+
jobs:
22+
classify:
23+
name: PR classifiers
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 10
26+
permissions:
27+
contents: read
28+
pull-requests: write # this job only; needed to publish the risk label and the summary comment
29+
steps:
30+
# This job must never check out or run code from the pull request. The only checkout
31+
# is the classifiers repository, at a pinned commit.
32+
- name: Get a token for the classifiers repository
33+
id: app
34+
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
35+
with:
36+
client-id: ${{ vars.CLASSIFIERS_APP_CLIENT_ID }}
37+
private-key: ${{ secrets.CLASSIFIERS_APP_KEY }}
38+
repositories: classifiers
39+
permission-contents: read
40+
41+
- name: Fetch the classifiers
42+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
43+
with:
44+
repository: getsentry/classifiers
45+
ref: e9cc499bbf218d6166d201a895f7bed206a92c60
46+
token: ${{ steps.app.outputs.token }}
47+
path: .classifiers
48+
persist-credentials: false
49+
50+
- name: Classify the pull request
51+
id: classify
52+
uses: ./.classifiers/actions/pr
53+
env:
54+
# On this step only, never at job or workflow level.
55+
AI_GATEWAY_API_KEY: ${{ secrets.AI_GATEWAY_API_KEY }}
56+
with:
57+
repo: ${{ github.repository }}
58+
pr-number: ${{ github.event.pull_request.number }}
59+
expected-head-sha: ${{ github.event.pull_request.head.sha }}
60+
result-path: pr-classifiers-result.json
61+
publish-label: true
62+
publish-comment: true
63+
64+
- name: Upload the result
65+
if: always()
66+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
67+
with:
68+
name: pr-classifiers-${{ github.event.pull_request.number }}
69+
path: pr-classifiers-result.json
70+
if-no-files-found: warn
71+
retention-days: 30

‎.github/workflows/pr-risk-jev.yml‎

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)