@@ -12,10 +12,23 @@ concurrency:
1212jobs :
1313 pre-commit :
1414 runs-on : ubuntu-latest
15- if : false == startsWith(github.event.pull_request.head.ref, 'datadog-api-spec/generated/') && !contains(github.event.pull_request.labels.*.name, 'ci/skip/pre-commit')
15+ if : >
16+ github.event.pull_request.draft == false &&
17+ !contains(github.event.pull_request.labels.*.name, 'ci/skip') &&
18+ !contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/') &&
19+ !contains(github.event.pull_request.head.ref, 'datadog-api-spec/generated/')
1620 steps :
17- - uses : actions/checkout@v1
18- - uses : actions/setup-python@v1
21+ - name : Get GitHub App token
22+ id : get_token
23+ uses : tibdex/github-app-token@v1.3.0
24+ with :
25+ app_id : ${{ secrets.PIPELINE_GITHUB_APP_ID }}
26+ private_key : ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
27+ - uses : actions/checkout@v2
28+ with :
29+ fetch-depth : 0
30+ ref : ${{ github.event.pull_request.head.sha }}
31+ token : ${{ steps.get_token.outputs.token }}
1932 - name : Install pre-commit
2033 run : python -m pip install pre-commit
2134 - name : set PY
2437 with :
2538 path : ~/.cache/pre-commit
2639 key : pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
27- - name : Run pre-commit
28- run : pre-commit run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} --show-diff-on-failure --color=always
40+ - id : pre_commit
41+ name : Run pre-commit
42+ if : github.event.action != 'closed' && github.event.pull_request.merged != true
43+ run : |
44+ pre-commit run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} --show-diff-on-failure --color=always
45+ - name : Commit changes
46+ if : ${{ failure() }}
47+ run : |-
48+ git add -A
49+ git config user.name "${GIT_AUTHOR_NAME}"
50+ git config user.email "${GIT_AUTHOR_EMAIL}"
51+ git commit -m "pre-commit fixes"
52+ git push origin HEAD:${{ github.event.pull_request.head.ref }}
53+ exit 1
2954
3055 test :
3156 strategy :
0 commit comments