Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/auto-spotless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
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:
create-patch:
runs-on: ubuntu-latest
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: 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: Spotless
run: ./gradlew spotlessApply

- name: Create patch
run: git diff > patch

- name: Upload patch
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
path: patch

apply-patch:
runs-on: ubuntu-latest
needs: create-patch
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Check out PR branch
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:
# not using secrets.GITHUB_TOKEN since pushes from that token do not run workflows
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 "✅ \`fix:spotless\` applied successfully"

- if: failure()
env:
GH_TOKEN: ${{ steps.otelbot-token.outputs.token }}
run: |
gh pr comment $PR_NUM --body "❌ \`fix:spotless\` failed, see logs: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
testing

# OpenTelemetry Instrumentation for Java

[![Release](https://img.shields.io/github/v/release/open-telemetry/opentelemetry-java-instrumentation?include_prereleases&style=)](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/)
Expand Down
Loading