|
9 | 9 | permissions: |
10 | 10 | pull-requests: write |
11 | 11 |
|
| 12 | +concurrency: |
| 13 | + group: ci-${{ github.event.pull_request.number || github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
12 | 16 | jobs: |
| 17 | + format: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + name: Auto-format |
| 20 | + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v6 |
| 23 | + with: |
| 24 | + ref: ${{ github.head_ref }} |
| 25 | + token: ${{ secrets.PR_TOKEN }} |
| 26 | + |
| 27 | + - name: Check if last commit is from bot |
| 28 | + id: check-bot |
| 29 | + run: | |
| 30 | + LAST_AUTHOR=$(git log -1 --format='%an') |
| 31 | + if [ "$LAST_AUTHOR" = "github-actions[bot]" ]; then |
| 32 | + echo "skip=true" >> "$GITHUB_OUTPUT" |
| 33 | + else |
| 34 | + echo "skip=false" >> "$GITHUB_OUTPUT" |
| 35 | + fi |
| 36 | +
|
| 37 | + - name: Set up JDK 21 |
| 38 | + if: steps.check-bot.outputs.skip != 'true' |
| 39 | + uses: actions/setup-java@v5 |
| 40 | + with: |
| 41 | + java-version: 21 |
| 42 | + distribution: 'corretto' |
| 43 | + |
| 44 | + - name: Cache compiled buildscripts |
| 45 | + if: steps.check-bot.outputs.skip != 'true' |
| 46 | + uses: actions/cache@v5 |
| 47 | + with: |
| 48 | + key: ${{ runner.os }}-gradle-${{ hashFiles('buildSrc/**/*.kts') }} |
| 49 | + path: | |
| 50 | + ./buildSrc/build |
| 51 | +
|
| 52 | + - name: Setup Gradle |
| 53 | + if: steps.check-bot.outputs.skip != 'true' |
| 54 | + uses: gradle/actions/setup-gradle@v6 |
| 55 | + with: |
| 56 | + cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} |
| 57 | + gradle-home-cache-includes: | |
| 58 | + caches |
| 59 | +
|
| 60 | + - name: Run spotlessApply |
| 61 | + if: steps.check-bot.outputs.skip != 'true' |
| 62 | + run: ./gradlew spotlessApply |
| 63 | + |
| 64 | + - name: Commit formatting changes |
| 65 | + if: steps.check-bot.outputs.skip != 'true' |
| 66 | + run: | |
| 67 | + if [ -n "$(git status --porcelain)" ]; then |
| 68 | + git config user.name "github-actions[bot]" |
| 69 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 70 | + git add -A |
| 71 | + git commit -m "Auto-format: apply spotless formatting" |
| 72 | + git push |
| 73 | + fi |
| 74 | +
|
13 | 75 | build: |
| 76 | + needs: [format] |
| 77 | + if: always() && !cancelled() |
14 | 78 | runs-on: ${{ matrix.os }} |
15 | 79 | name: Java ${{ matrix.java }} ${{ matrix.os }} |
16 | 80 | strategy: |
|
0 commit comments