-
Notifications
You must be signed in to change notification settings - Fork 8
39 lines (31 loc) · 1.15 KB
/
precommit-validate.yml
File metadata and controls
39 lines (31 loc) · 1.15 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
name: Run pre-commit
on: [ pull_request ]
# Declare default permissions as read only.
permissions: read-all
jobs:
pre-commit:
runs-on: ubuntu-latest
name: pre-commit
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: 3.x
- name: Remove rh-pre-commit hook (requires VPN)
uses: mikefarah/yq@5a7e72a743649b1b3a47d1a1d8214f3453173c51 # v4.52.4
with:
cmd: yq -i 'del( .repos[] | select(.rev == "rh-pre-commit-*"))' .pre-commit-config.yaml
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
- name: Check if there are changes
id: changes
run: |
git checkout HEAD -- .pre-commit-config.yaml
echo "changed=$(git status --porcelain | wc -l)" >> $GITHUB_OUTPUT
- name: Fail if changes found
if: steps.changes.outputs.changed >= 1
run: |
echo "Uncommitted changes exist. Failing."
echo
git status --porcelain
exit 1