@@ -10,36 +10,40 @@ permissions:
1010
1111jobs :
1212 build :
13+ name : build
1314 runs-on : ubuntu-latest
1415
1516 steps :
1617 - name : Checkout branch
1718 uses : actions/checkout@v4
1819 with :
19- ref : ${{ github.head_ref }}
20+ ref : ${{ github.head_ref || github.ref_name }}
2021 token : ${{ secrets.GITHUB_TOKEN }}
22+ fetch-depth : 0
2123
2224 - name : Make gradlew executable
2325 run : chmod +x ./gradlew
2426
25- - name : Apply Spotless formatting if needed
26- id : spotless_apply
27+ - name : Check and apply Spotless formatting
28+ id : spotless
2729 run : |
2830 if ./gradlew spotlessKotlinCheck; then
29- echo "already_clean =true" >> $GITHUB_OUTPUT
31+ echo "clean =true" >> $GITHUB_OUTPUT
3032 else
3133 ./gradlew spotlessApply
32- echo "already_clean =false" >> $GITHUB_OUTPUT
34+ echo "clean =false" >> $GITHUB_OUTPUT
3335 fi
3436
35- - name : Commit Spotless fixes
36- if : steps.spotless_apply .outputs.already_clean == 'false'
37+ - name : Commit and push Spotless fixes
38+ if : steps.spotless .outputs.clean == 'false'
3739 run : |
3840 git config user.name "github-actions[bot]"
3941 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
4042 git add .
41- git diff --cached --quiet || git commit -m "chore: auto-fix Spotless formatting"
42- git push origin HEAD:${{ github.head_ref }}
43+ git commit -m "chore: auto-fix Spotless formatting"
44+ git push origin HEAD:${{ github.head_ref || github.ref_name }}
45+ exit 0
4346
4447 - name : Build with Gradle Wrapper
45- run : ./gradlew build
48+ if : steps.spotless.outputs.clean == 'true'
49+ run : ./gradlew build
0 commit comments