Prevent default message round-trip failures for module-backed payload… #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Format PR Code | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| - ready_for_review | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - "**/*.java" | |
| jobs: | |
| format: | |
| if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }} | |
| fetch-depth: 0 | |
| - name: Set up Java 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: "21" | |
| cache: gradle | |
| - name: Expose Java 21 to Gradle toolchains | |
| run: | | |
| echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" | |
| echo "ORG_GRADLE_JAVA_INSTALLATIONS_PATHS=$JAVA_HOME" >> "$GITHUB_ENV" | |
| java -version | |
| javac -version | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Format Java sources | |
| run: ./gradlew formatJava | |
| - name: Commit formatted changes | |
| run: | | |
| if git diff --quiet; then | |
| echo "No formatting changes detected" | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git commit -m "Apply Palantir Java Format" | |
| git push | |
| check-format: | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout branch | |
| uses: actions/checkout@v4 | |
| - name: Set up Java 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: "21" | |
| cache: gradle | |
| - name: Expose Java 21 to Gradle toolchains | |
| run: | | |
| echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" | |
| echo "ORG_GRADLE_JAVA_INSTALLATIONS_PATHS=$JAVA_HOME" >> "$GITHUB_ENV" | |
| java -version | |
| javac -version | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| - name: Check Java formatting | |
| run: ./gradlew checkFormatJava | |
| - name: Explain how to fix formatting | |
| if: failure() | |
| run: | | |
| echo "Java formatting check failed." | |
| echo "This pull request comes from a fork, so CI cannot push formatting commits back to the branch." | |
| echo "Run './gradlew formatJava' locally and push the formatted changes to update the PR." |