-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (56 loc) · 2.21 KB
/
pre-commit-hooks.yaml
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
56
57
58
59
60
61
62
63
64
on:
workflow_call:
inputs:
ignoreErrors:
required: false
type: boolean
default: false
description: whether or not to ignore errors
env:
CHECK_NAME: Pre-commit hooks
jobs:
pre-commit:
name: Pre-commit hooks
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
statuses: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set status pending
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
-f "state=pending" -f "description=PR pre-commit checks are running" \
-f "context=${{ env.CHECK_NAME }}"
- name: Checkout reusable-workflows repository
uses: actions/checkout@v4
with:
repository: dnlopes/github-workflows
path: actions
- name: Install tools
uses: ./actions/.github/actions/install-common-tools
- name: Run pre-commit hooks
uses: pre-commit/action@v3.0.1
- name: Set status success
if: ${{ success() || inputs.IgnoreErrors == true }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
-f "state=success" -f "description=PR pre-commit checks were successful" \
-f "context=${{ env.CHECK_NAME }}"
- name: Set status failure
if: ${{ failure() && inputs.IgnoreErrors == false }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
-f "state=failure" -f "description=PR pre-commit checks failed validations!" \
-f "context=${{ env.CHECK_NAME }}"