Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Apply Spotless Formatting

on:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
format:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Apply Spotless formatting
run: mvn spotless:apply

- name: Commit changes if any
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
if ! git diff --quiet --staged; then
git commit -m "Apply Spotless formatting"
git pull --rebase origin ${{ github.head_ref || github.ref_name }}
git push origin HEAD:${{ github.head_ref || github.ref_name }}
else
echo "No formatting changes to commit."
fi
Loading