Skip to content

testing

testing #3

Workflow file for this run

name: Auto spotless
on:
pull_request_target:
types:
- opened
- synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
outputs:
patch-created: ${{ steps.create-patch-file.outputs.nonempty }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Free disk space
run: .github/scripts/gha-free-disk-space.sh
- name: Set up JDK for running Gradle
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
with:
distribution: temurin
java-version-file: .java-version
- name: Setup Gradle
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4.3.1
with:
cache-read-only: true
- name: Check out PR branch
env:
GH_TOKEN: ${{ github.token }}
run: gh pr checkout ${{ github.event.pull_request.number }}
- name: Spotless
run: ./gradlew spotlessApply
- id: create-patch-file
name: Create patch file
run: |
git diff > patch
if [ -s patch ]; then
echo "nonempty=true" >> "$GITHUB_OUTPUT"
fi
- name: Upload patch file
if: steps.create-patch-file.outputs.nonempty == 'true'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
path: patch
name: patch
apply:
runs-on: ubuntu-latest
needs: check
if: needs.check.outputs.patch-created == 'true'
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Check out PR branch
env:
GH_TOKEN: ${{ github.token }}
run: gh pr checkout ${{ github.event.pull_request.number }}
- name: Download patch
uses: actions/download-artifact@v4
with:
name: patch
- name: Use CLA approved github bot
# IMPORTANT do not call the .github/scripts/use-cla-approved-bot.sh
# since that script could have been compromised in the PR branch
run: |
git config user.name otelbot
git config user.email [email protected]
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
id: otelbot-token
with:
app-id: ${{ vars.OTELBOT_APP_ID }}
private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }}
- name: Apply patch and push
env:
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
run: |
git apply patch
git commit -a -m "./gradlew spotlessApply"
git push
- if: success()
env:
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
run: |
gh pr comment $PR_NUM --body "🔧 The result from \`./gradlew spotlessApply\` was committed to the PR branch."
- if: failure()
env:
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
run: |
gh pr comment $PR_NUM --body "❌ The result from \`./gradlew spotlessApply\` could not be committed to the PR branch, see logs: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID."