2021-05-01 11:27:23 +00:00
|
|
|
name: "Pre-commit consistency check"
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
pull_request:
|
|
|
|
|
2021-06-11 17:56:14 +00:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.head_ref }}-precommit
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2021-05-01 11:27:23 +00:00
|
|
|
jobs:
|
|
|
|
pre-commit-check:
|
|
|
|
name: Run pre-commit checks
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
2021-07-12 08:33:02 +00:00
|
|
|
- uses: getsentry/action-github-app-token@v1
|
|
|
|
id: get-app-token
|
|
|
|
with:
|
|
|
|
app_id: ${{ secrets.K8S_AT_HOME_APP_ID }}
|
|
|
|
private_key: ${{ secrets.K8S_AT_HOME_APP_PRIVATE_KEY }}
|
|
|
|
|
2021-05-01 11:27:23 +00:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
2021-07-12 08:33:02 +00:00
|
|
|
token: ${{ steps.get-app-token.outputs.token }}
|
2021-05-01 11:27:23 +00:00
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- uses: dorny/paths-filter@v2
|
|
|
|
id: filter
|
|
|
|
with:
|
|
|
|
list-files: shell
|
|
|
|
filters: |
|
|
|
|
addedOrModified:
|
|
|
|
- added|modified: '**'
|
|
|
|
|
|
|
|
# run only if changed files were detected
|
|
|
|
- name: Run against changes
|
2021-05-01 11:52:30 +00:00
|
|
|
uses: pre-commit/action@v2.0.3
|
2021-05-01 11:27:23 +00:00
|
|
|
if: steps.filter.outputs.addedOrModified == 'true'
|
|
|
|
with:
|
|
|
|
extra_args: --files ${{ steps.filter.outputs.addedOrModified_files }}
|
|
|
|
|
|
|
|
# run if no changed files were detected (e.g. workflow_dispatch on master branch)
|
|
|
|
- name: Run against all files
|
2021-05-01 11:52:30 +00:00
|
|
|
uses: pre-commit/action@v2.0.3
|
2021-05-01 11:27:23 +00:00
|
|
|
if: steps.filter.outputs.addedOrModified != 'true'
|
|
|
|
with:
|
|
|
|
extra_args: --all-files
|
2021-07-12 08:33:02 +00:00
|
|
|
|
|
|
|
# CI Passed
|
|
|
|
- name: "add label: ok"
|
|
|
|
uses: actions-ecosystem/action-add-labels@v1
|
|
|
|
if: ${{ success() }}
|
|
|
|
with:
|
|
|
|
github_token: ${{ steps.get-app-token.outputs.token }}
|
|
|
|
labels: "precommit:ok"
|
|
|
|
|
|
|
|
- name: "remove label: failed"
|
|
|
|
uses: actions-ecosystem/action-remove-labels@v1
|
|
|
|
if: ${{ success() }}
|
|
|
|
with:
|
|
|
|
github_token: ${{ steps.get-app-token.outputs.token }}
|
|
|
|
labels: "precommit:failed"
|
|
|
|
|
|
|
|
# CI Failed
|
|
|
|
- name: "add label: failed"
|
|
|
|
uses: actions-ecosystem/action-add-labels@v1
|
|
|
|
if: ${{ failure() }}
|
|
|
|
with:
|
|
|
|
github_token: ${{ steps.get-app-token.outputs.token }}
|
|
|
|
labels: "precommit:failed"
|
|
|
|
|
|
|
|
- name: "remove label: ok"
|
|
|
|
uses: actions-ecosystem/action-remove-labels@v1
|
|
|
|
if: ${{ failure() }}
|
|
|
|
with:
|
|
|
|
github_token: ${{ steps.get-app-token.outputs.token }}
|
|
|
|
labels: "precommit:ok"
|