From 481c62c927a3ac7fb40b37bb98e2db12a8b09230 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Mon, 30 Nov 2026 15:13:58 +0000 Subject: [PATCH] feat(pr-classifiers): Comment as the GitHub App Add comment-as-app, which writes the summary comment with a token of the classifiers app scoped to the calling repository's pull requests, instead of the workflow token as github-actions[bot]. Co-Authored-By: Phil Niedertscheider <30923007+philprime@users.noreply.github.com> --- CHANGELOG.md | 1 + pr-classifiers/README.md | 1 + pr-classifiers/action.yml | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19fb0aa..8f3ed6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Features - PR Classifiers - Add an action that runs the internal `getsentry/classifiers` action on a pull request, so repositories no longer copy the token, checkout and upload steps. The fact sheet is read from the repository itself, at `.github/classifiers.toml`. ([#188](https://github.com/getsentry/github-workflows/pull/188)) +- PR Classifiers - Add `comment-as-app` to write the summary comment as the GitHub App instead of `github-actions[bot]`. ([#190](https://github.com/getsentry/github-workflows/pull/190)) - Skip CI - Add an action that tells whether a push to a pull request only changes files that need no CI, such as Markdown, since a head whose run passed. Jobs gated on its `skip` output don't run for a CHANGELOG fix-up. ([#187](https://github.com/getsentry/github-workflows/pull/187)) ## 3.5.0 diff --git a/pr-classifiers/README.md b/pr-classifiers/README.md index 921b6e0..d6c934f 100644 --- a/pr-classifiers/README.md +++ b/pr-classifiers/README.md @@ -66,6 +66,7 @@ Keep the `concurrency` block exactly as in the example. It puts runs started by | `classifiers-ref` | No | pinned commit | Commit of `getsentry/classifiers` to run | | `publish-label` | No | `true` | `true` lets the action own the labels it publishes | | `publish-comment` | No | `false` | `true` keeps one summary comment on the pull request | +| `comment-as-app` | No | `false` | `true` writes the summary comment as the GitHub App from `app-client-id` instead of `github-actions[bot]`. The app must be installed on the repository with pull requests write access | | `upload-result` | No | `true` | `true` uploads the public result JSON as the artifact `pr-classifiers-` | The fact sheet is read from the pull request's base commit, so a pull request that changes the sheet is scored with the sheet already merged, and such a pull request is never `low`. diff --git a/pr-classifiers/action.yml b/pr-classifiers/action.yml index 32dc176..f68ab6d 100644 --- a/pr-classifiers/action.yml +++ b/pr-classifiers/action.yml @@ -24,6 +24,10 @@ inputs: description: "'true' keeps one summary comment on the pull request. Needs `pull-requests: write`." required: false default: 'false' + comment-as-app: + description: "'true' writes the summary comment as the GitHub App instead of `github-actions[bot]`. The app must be installed on this repository with pull requests write access." + required: false + default: 'false' upload-result: description: "'true' uploads the public result JSON as a workflow artifact." required: false @@ -77,6 +81,17 @@ runs: path: .classifiers persist-credentials: false + - name: Get a token for the summary comment + id: comment-app + if: ${{ inputs.publish-comment == 'true' && inputs.comment-as-app == 'true' }} + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + with: + client-id: ${{ inputs.app-client-id }} + private-key: ${{ inputs.app-private-key }} + repositories: ${{ github.event.repository.name }} + # The token can comment on this repository's pull requests and nothing else. + permission-pull-requests: write + - name: Classify the pull request id: classify # A local path in a composite action resolves against the workspace, where the @@ -92,6 +107,9 @@ runs: result-path: pr-classifiers-result.json publish-label: ${{ inputs.publish-label }} publish-comment: ${{ inputs.publish-comment }} + # Empty unless comment-as-app is on; the action then comments with the workflow token. + comment-token: ${{ steps.comment-app.outputs.token }} + comment-author: ${{ steps.comment-app.outputs.app-slug && format('{0}[bot]', steps.comment-app.outputs.app-slug) || '' }} - name: Upload the result if: ${{ always() && inputs.upload-result == 'true' }}