@@ -12,10 +12,23 @@ concurrency:
12
12
jobs :
13
13
pre-commit :
14
14
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/')
16
20
steps :
17
- - uses : actions/checkout@v1
18
- - uses : actions/setup-python@v1
21
+ - name : Get GitHub App token
22
+ id : get_token
23
+
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 }}
19
32
- name : Install pre-commit
20
33
run : python -m pip install pre-commit
21
34
- name : set PY
24
37
with :
25
38
path : ~/.cache/pre-commit
26
39
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
29
54
30
55
test :
31
56
strategy :
0 commit comments