@@ -31,12 +31,22 @@ jobs:
3131 - name : Setup Build
3232 uses : ./.github/actions/build_setup
3333
34+ - name : Check if PR is from a fork
35+ id : fork-check
36+ run : |
37+ if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
38+ echo "is_fork=true" >> $GITHUB_OUTPUT
39+ else
40+ echo "is_fork=false" >> $GITHUB_OUTPUT
41+ fi
42+ shell : bash
43+
3444 - name : Run Spotless Formatting Check with Gradle
3545 id : build
36- run : ./gradlew --info spotlessCheck
46+ run : ./gradlew --info --stacktrace spotlessCheck
3747
3848 - name : Attempt to make a PR fixing spotless errors
39- if : failure() && steps.build.conclusion == 'failure'
49+ if : failure() && steps.build.conclusion == 'failure' && steps.fork-check.outputs.is_fork == 'false'
4050 run : |
4151 git reset --hard
4252 git checkout "${PR_BRANCH}"
5464 --body "Automatic spotless apply to fix formatting errors, applies to PR #${PR_NUMBER}" \
5565 2>&1 | tee pr-message.log || true
5666 gh pr comment "${PR_BRANCH}" -F pr-message.log || true
57- shell : bash # ensures set -eo pipefail
67+ shell : bash
5868 env :
5969 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6070 PR_BRANCH : ${{ github.event.pull_request.head.ref }}
6171 PR_NUMBER : ${{ github.event.pull_request.number }}
6272 FIXED_BRANCH : ${{ github.head_ref }}-spotless-fixes
73+
74+ - name : Comment to PR if from fork and formatting failed
75+ if : failure() && steps.build.conclusion == 'failure' && steps.fork-check.outputs.is_fork == 'true'
76+ run : |
77+ gh pr comment ${{ github.event.pull_request.number }} --body "I can't get automatic fixes by spotless in CI. Please run '. /gradlew spotlessApply' and push again."
78+ env :
79+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments