Skip to content

Commit 884ac92

Browse files
committed
chore: implement pre lint auto-fix pipeline
Related: AAP-64628
1 parent 4266bc7 commit 884ac92

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

.github/workflows/pre.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: pre
3+
on:
4+
merge_group:
5+
branches: ["main", "devel/*"]
6+
push:
7+
branches: ["main", "devel/*"]
8+
tags:
9+
- "v*.*"
10+
pull_request:
11+
# 'closed' is missing to avoid double triggering on PR merge
12+
# 'edited' is missing to allow us to edit PR title/description without triggering
13+
types: [synchronize, opened, reopened]
14+
branches: ["main", "devel/*"]
15+
permissions:
16+
contents: write
17+
id-token: write
18+
pull-requests: write
19+
checks: write
20+
jobs:
21+
prek:
22+
runs-on: ubuntu-24.04
23+
steps:
24+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
with:
26+
fetch-depth: 0 # we need tags for dynamic versioning
27+
show-progress: false
28+
29+
# needed by our system prek hooks that rely un local uv.lock
30+
- uses: astral-sh/setup-uv@v7
31+
32+
- uses: j178/prek-action@v1
33+
with:
34+
install-only: true
35+
36+
- name: Run prek with auto-fix
37+
id: prek
38+
run: |
39+
EXIT_CODE=0
40+
prek run --all-files || EXIT_CODE=$?
41+
if [ -n "$(git status --porcelain)" ]; then
42+
git config --global user.email ansible-devtools@redhat.com
43+
git config --global user.name "Ansible DevTools"
44+
git add -A
45+
git commit -m 'Prek auto-fixes'
46+
prek run --all-files || EXIT_CODE=$?
47+
if [ $EXIT_CODE -eq 0 ]; then
48+
git push origin || EXIT_CODE=$?
49+
fi
50+
fi
51+
exit $EXIT_CODE

0 commit comments

Comments
 (0)