name: format code on: pull_request: jobs: format-code: name: Format Code runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: 'recursive' - name: set up JDK 17 uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5 with: distribution: 'temurin' java-version: '17' - name: Setup Gradle uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0 with: cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} - name: Format with spotlessApply run: ./gradlew spotlessApply # 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