name: CI on: pull_request: push: branches: [ "master" ] permissions: contents: write concurrency: group: ci-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: pr-title: name: Conventional PR title if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - name: Check the title against the Conventional Commits spec env: PR_TITLE: ${{ github.event.pull_request.title }} run: | types='build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test' if [[ "$PR_TITLE" =~ ^($types)(\([a-z0-9._/-]+\))?!?:\ .+ ]]; then echo "OK: $PR_TITLE" exit 0 fi echo "::error::PR title is not a Conventional Commit: $PR_TITLE" echo "Expected '(): ', for example:" echo " feat(game): start a wild battle when a player steps in grass" echo " fix(codegen): merge the duplicate branches in the text parser" echo "Valid types: ${types//|/, }" echo "Append '!' after the type or scope to mark a breaking change." exit 1 ci: name: Spotless and check runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v7 with: submodules: recursive # On pull requests check out the branch itself, not the detached merge # commit, so the formatting commit can be pushed back. ref: >- ${{ github.event_name != 'pull_request' && github.sha || github.event.pull_request.head.repo.full_name == github.repository && github.head_ref || format('refs/pull/{0}/head', github.event.pull_request.number) }} token: ${{ secrets.GITHUB_TOKEN }} - name: Set up JDK 25 uses: actions/setup-java@v5 with: distribution: temurin java-version: "25" - name: Set up Gradle uses: gradle/actions/setup-gradle@v6 - name: Apply Spotless and push formatting changes if: >- github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.user.login != 'renovate[bot]' && !startsWith(github.head_ref, 'release-please--') run: | ./gradlew spotlessApply if git diff --quiet; then echo "Nothing to format." exit 0 fi git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add -u git commit -m "chore(style): spotlessApply" git push - name: Run checks run: ./gradlew check