Skip to content

Commit 14c8e84

Browse files
Refactor: Update formatter.yml
1 parent 5e02821 commit 14c8e84

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

.github/workflows/formatter.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1-
name: Apply Spotless Formatting
1+
name: 🧼 Apply Spotless Formatting
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
74
push:
8-
branches:
9-
- main
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
109

1110
jobs:
1211
format:
1312
runs-on: ubuntu-latest
1413
concurrency:
15-
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
14+
group: ${{ github.workflow }}-${{ github.ref_name }}
1615
cancel-in-progress: true
1716

1817
steps:
1918
- name: Checkout repository
2019
uses: actions/checkout@v4
2120
with:
22-
ref: ${{ github.head_ref || github.ref_name }}
2321
fetch-depth: 0
2422

2523
- name: Set up JDK 17
@@ -32,15 +30,15 @@ jobs:
3230
- name: Apply Spotless formatting
3331
run: mvn spotless:apply
3432

35-
- name: Commit changes if any
33+
- name: Commit and push formatting changes
3634
run: |
3735
git config --global user.name "github-actions[bot]"
3836
git config --global user.email "github-actions[bot]@users.noreply.github.com"
39-
git add .
40-
if ! git diff --quiet --staged; then
37+
git add -A
38+
if ! git diff --cached --quiet; then
4139
git commit -m "Apply Spotless formatting"
42-
git pull --rebase origin ${{ github.head_ref || github.ref_name }}
43-
git push origin HEAD:${{ github.head_ref || github.ref_name }}
40+
git pull --rebase --autostash origin ${{ github.ref_name }}
41+
git push origin HEAD:${{ github.ref_name }}
4442
else
45-
echo "No formatting changes to commit."
43+
echo "No formatting changes to commit."
4644
fi

0 commit comments

Comments
 (0)