-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: set permissions and use github token (#921)
Instead of using a GitHub App + Private Key, just use the GitHub Actions token with scoped permissions to commit back pre-commit changes. --------- Co-authored-by: Jeffrey Hung <[email protected]>
- Loading branch information
1 parent
197c676
commit 507ed7c
Showing
1 changed file
with
17 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,13 @@ concurrency: | |
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: read | ||
contents: write | ||
statuses: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Get auth token | ||
id: token | ||
uses: getsentry/[email protected] | ||
with: | ||
app_id: ${{ secrets.SENTRY_INTERNAL_APP_ID }} | ||
private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }} | ||
- name: Get changed files | ||
id: changes | ||
uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0 | ||
|
@@ -40,14 +39,25 @@ jobs: | |
pre-commit install | ||
- name: Run pre-commit on PR commits | ||
id: pre-commit_results | ||
continue-on-error: true | ||
run: | | ||
jq '.[]' --raw-output <<< '${{steps.changes.outputs.all_files}}' | | ||
# Run pre-commit to lint and format check files that were changed (but not deleted) compared to master. | ||
xargs pre-commit run --files | ||
- name: Get auth token | ||
id: token | ||
if: ${{ steps.pre-commit_results.outcome == 'failure' }} | ||
uses: getsentry/[email protected] | ||
with: | ||
app_id: ${{ vars.SENTRY_INTERNAL_APP_ID }} | ||
private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }} | ||
|
||
- name: Apply any pre-commit fixed files | ||
if: ${{ steps.pre-commit_results.outcome == 'failure' }} | ||
# note: this runs "always" or else it's skipped when pre-commit fails | ||
uses: getsentry/action-github-commit@31f6706ca1a7b9ad6d22c1b07bf3a92eabb05632 # v2.0.0 | ||
uses: getsentry/action-github-commit@v2.1.0 | ||
with: | ||
github-token: ${{ steps.token.outputs.token }} | ||
message: ':hammer_and_wrench: apply pre-commit fixes' |