File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Apply Spotless Formatting
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+ push :
8+ branches :
9+ - main
10+
11+ jobs :
12+ format :
13+ runs-on : ubuntu-latest
14+ concurrency :
15+ group : ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
16+ cancel-in-progress : true
17+
18+ steps :
19+ - name : Checkout repository
20+ uses : actions/checkout@v4
21+ with :
22+ ref : ${{ github.head_ref || github.ref_name }}
23+ fetch-depth : 0
24+
25+ - name : Set up JDK 17
26+ uses : actions/setup-java@v4
27+ with :
28+ java-version : ' 17'
29+ distribution : ' temurin'
30+ cache : maven
31+
32+ - name : Apply Spotless formatting
33+ run : mvn spotless:apply
34+
35+ - name : Commit changes if any
36+ run : |
37+ git config --global user.name "github-actions[bot]"
38+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
39+ git add .
40+ if ! git diff --quiet --staged; then
41+ 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 }}
44+ else
45+ echo "No formatting changes to commit."
46+ fi
You can’t perform that action at this time.
0 commit comments