Repository navigation
69 lines (61 loc) · 2.53 KB
/
Copy pathpre-commit-hooks.yaml
File metadata and controls
69 lines (61 loc) · 2.53 KB
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
65
66
67
68
69
on:
workflow_call:
inputs:
runsOn:
required: false
type: string
default: ubuntu-latest
description: runner label for the job, for example the name of a self-hosted runner scale set
ignoreErrors:
required: false
type: boolean
default: false
description: whether or not to ignore errors
env:
CHECK_NAME: Pre-commit CI
jobs:
pre-commit:
name: Pre-commit hooks
runs-on: ${{ inputs.runsOn }}
permissions:
contents: read
pull-requests: read
statuses: write
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- 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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
repository: davidnlopes/Reusable.Workflows
path: actions
- name: Install tools
uses: ./actions/.github/actions/install-common-tools
- name: Run pre-commit hooks
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # 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 }}"