Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pr-classifiers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<number>` |

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`.
Expand Down
18 changes: 18 additions & 0 deletions pr-classifiers/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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' }}
Expand Down
Loading