name: format code on: pull_request: jobs: format-code: name: Format Code runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: submodules: 'recursive' - name: set up JDK 17 uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17' - name: Cache Gradle packages uses: actions/cache@v4 with: path: | ~/.gradle/caches ~/.gradle/wrapper key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} restore-keys: | ${{ runner.os }}-gradle- - name: Make format run: make format # actions/checkout fetches only a single commit in a detached HEAD state. Therefore # we need to pass the current branch, otherwise we can't commit the changes. # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. - name: Commit Formatted Code run: ./scripts/commit-formatted-code.sh $GITHUB_HEAD_REF