File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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+
15+ steps :
16+ - name : Checkout repository
17+ uses : actions/checkout@v4
18+ with :
19+ ref : ${{ github.head_ref || github.ref_name }}
20+ fetch-depth : 0
21+
22+ - name : Set up JDK 17
23+ uses : actions/setup-java@v4
24+ with :
25+ java-version : ' 17'
26+ distribution : ' temurin'
27+ cache : maven
28+
29+ - name : Apply Spotless formatting
30+ run : mvn spotless:apply
31+
32+ - name : Commit changes if any
33+ run : |
34+ git config --global user.name "github-actions[bot]"
35+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
36+ git add .
37+ if ! git diff --quiet --staged; then
38+ git commit -m "Apply Spotless formatting"
39+ git pull --rebase origin ${{ github.head_ref }}
40+ git push origin HEAD:${{ github.head_ref }}
41+ else
42+ echo "No formatting changes to commit."
43+ fi
You can’t perform that action at this time.
0 commit comments