Skip to content

Commit 8631693

Browse files
committed
feat(ci): autoformat commits
1 parent 6dd4826 commit 8631693

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/auto-format.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This workflow runs on every push and automatically applies formatting using mise format
2+
name: Auto-format code
3+
4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.ref }}
6+
cancel-in-progress: true
7+
8+
on:
9+
push:
10+
branches:
11+
- "**"
12+
13+
jobs:
14+
format:
15+
runs-on: ubuntu-slim
16+
# Skip if commit is already from this auto-format workflow to avoid infinite loops
17+
if: "!contains(github.event.head_commit.message, '[LeshyBot] Apply automatic formatting')"
18+
steps:
19+
- uses: actions/create-github-app-token@v2
20+
id: generate-token
21+
with:
22+
app-id: ${{ secrets.LESHY_APP_ID }}
23+
private-key: ${{ secrets.LESHY_APP_PRIVATE_KEY }}
24+
25+
- uses: actions/checkout@v6
26+
with:
27+
token: ${{ steps.generate-token.outputs.token }}
28+
fetch-depth: 0
29+
30+
- uses: jdx/mise-action@v3
31+
- run: mise format
32+
33+
- name: Check for changes
34+
id: check-changes
35+
run: |
36+
if [[ -n $(git status --porcelain) ]]; then
37+
echo "has_changes=true" >> $GITHUB_OUTPUT
38+
else
39+
echo "has_changes=false" >> $GITHUB_OUTPUT
40+
fi
41+
42+
- name: Commit and push formatting changes
43+
if: steps.check-changes.outputs.has_changes == 'true'
44+
run: |
45+
git config user.name "LeshyBot"
46+
git add .
47+
git commit -m "[LeshyBot] Apply automatic formatting"
48+
git push

0 commit comments

Comments
 (0)