-
Notifications
You must be signed in to change notification settings - Fork 50
55 lines (52 loc) · 1.65 KB
/
pre-commit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# ⚠️ DO NOT EDIT THIS FILE, IT IS GENERATED BY COPIER ⚠️
# Changes here will be lost on a future update.
# See: https://github.com/ingadhoc/addons-repo-template
name: pre-commit
on:
push:
branches: "*.0"
pull_request_target:
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
id: setup-python
name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
-
name: Pre-commit cache
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ steps.setup-python.outputs.python-version }}|${{ hashFiles('.pre-commit-config.yaml') }}
-
id: precommit
name: Pre-commit
uses: pre-commit/action@v3.0.1
continue-on-error: true
-
name: Create status on success only
env:
PRECOMMIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PRECOMMIT_STATE: ${{ steps.precommit.outcome }}
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $PRECOMMIT_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
-d '{"state":"$PRECOMMIT_STATE","context":"pre-commit","target_url": "${{ github.event.pull_request.html_url }}"}' \
--fail
-
name: Set output if pre-commit failed
if: steps.precommit.outcome == 'failure'
run: |
exit 1