Skip to content

Commit c8bbee4

Browse files
committed
[IMP] precommit
1 parent a56b720 commit c8bbee4

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

.github/workflows/pre-commit.yml

+27-1
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@ name: pre-commit
77
on:
88
push:
99
branches: "*.0"
10-
pull_request:
10+
pull_request_target:
1111

1212
jobs:
1313
pre-commit:
1414
runs-on: ubuntu-latest
1515
steps:
1616
-
1717
name: Checkout
18+
if: github.event_name != 'pull_request_target'
1819
uses: actions/checkout@v4
20+
-
21+
name: Checkout
22+
if: github.event_name == 'pull_request_target'
23+
uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.event.pull_request.head.sha }}
1926
-
2027
id: setup-python
2128
name: Setup Python
@@ -30,5 +37,24 @@ jobs:
3037
path: ~/.cache/pre-commit
3138
key: pre-commit|${{ steps.setup-python.outputs.python-version }}|${{ hashFiles('.pre-commit-config.yaml') }}
3239
-
40+
id: precommit
3341
name: Pre-commit
3442
uses: pre-commit/[email protected]
43+
continue-on-error: true
44+
-
45+
name: Create commit status
46+
if: github.event_name == 'pull_request_target'
47+
run: |
48+
curl -L \
49+
-X POST \
50+
-H "Accept: application/vnd.github+json" \
51+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
52+
-H "X-GitHub-Api-Version: 2022-11-28" \
53+
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
54+
-d '{"state":"${{ steps.precommit.outcome }}","context":"pre-commit","target_url": "${{ github.event.pull_request.html_url }}"}' \
55+
--fail
56+
-
57+
name: Set output if pre-commit failed
58+
if: steps.precommit.outcome == 'failure'
59+
run: |
60+
exit 1

0 commit comments

Comments
 (0)