|
| 1 | +name: Metadata Update |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: # allow this to be manually triggered |
| 5 | + schedule: |
| 6 | + - cron: "00 1 * * *" # daily at 1:00 UTC |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +# Should only be one job running at a time to avoid conflicts with the metadata update branch |
| 12 | +concurrency: |
| 13 | + group: metadata-update |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + update: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: write # for git push to PR branch |
| 21 | + pull-requests: write # for adding label and assignee to PR |
| 22 | + |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 25 | + |
| 26 | + - name: Free disk space |
| 27 | + run: .github/scripts/gha-free-disk-space.sh |
| 28 | + |
| 29 | + - name: Set up JDK for running Gradle |
| 30 | + uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 |
| 31 | + with: |
| 32 | + distribution: temurin |
| 33 | + java-version-file: .java-version |
| 34 | + |
| 35 | + - name: Set up gradle |
| 36 | + uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1 |
| 37 | + |
| 38 | + - name: Collect telemetry |
| 39 | + run: ./instrumentation-docs/ci-collect.sh |
| 40 | + |
| 41 | + - name: Run documentation analyzer |
| 42 | + run: ./gradlew :instrumentation-docs:runAnalysis |
| 43 | + |
| 44 | + - name: Check for diff |
| 45 | + id: diffcheck |
| 46 | + run: | |
| 47 | + git add docs/instrumentation-list.yaml |
| 48 | + if ! git diff --cached --quiet; then |
| 49 | + echo "has_diff=true" >> $GITHUB_OUTPUT |
| 50 | + else |
| 51 | + echo "has_diff=false" >> $GITHUB_OUTPUT |
| 52 | + fi |
| 53 | +
|
| 54 | + - name: Use CLA approved github bot |
| 55 | + if: steps.diffcheck.outputs.has_diff == 'true' |
| 56 | + run: .github/scripts/use-cla-approved-bot.sh |
| 57 | + |
| 58 | + - uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 |
| 59 | + if: steps.diffcheck.outputs.has_diff == 'true' |
| 60 | + id: otelbot-token |
| 61 | + with: |
| 62 | + app-id: ${{ vars.OTELBOT_APP_ID }} |
| 63 | + private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }} |
| 64 | + |
| 65 | + - name: Find or create metadata update branch |
| 66 | + if: steps.diffcheck.outputs.has_diff == 'true' |
| 67 | + id: findbranch |
| 68 | + env: |
| 69 | + GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} |
| 70 | + run: | |
| 71 | + BRANCH_NAME="metadata-update-main" |
| 72 | + echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT |
| 73 | + if git ls-remote --exit-code --heads origin "$BRANCH_NAME"; then |
| 74 | + git fetch origin "$BRANCH_NAME" |
| 75 | + git checkout "$BRANCH_NAME" |
| 76 | + git merge origin/main --no-edit |
| 77 | + else |
| 78 | + git checkout -b "$BRANCH_NAME" origin/main |
| 79 | + fi |
| 80 | +
|
| 81 | + - name: Commit and push changes |
| 82 | + if: steps.diffcheck.outputs.has_diff == 'true' |
| 83 | + env: |
| 84 | + GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} |
| 85 | + run: | |
| 86 | + BRANCH_NAME="${{ steps.findbranch.outputs.branch }}" |
| 87 | + git commit -m "chore: update instrumentation list [automated]" || echo "No changes to commit." |
| 88 | + git push origin "$BRANCH_NAME" |
| 89 | +
|
| 90 | + - name: Create PR if needed |
| 91 | + if: steps.diffcheck.outputs.has_diff == 'true' |
| 92 | + id: createpr |
| 93 | + env: |
| 94 | + GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} |
| 95 | + run: | |
| 96 | + BRANCH_NAME="${{ steps.findbranch.outputs.branch }}" |
| 97 | + PR_EXISTS=$(gh pr list --state open --head "$BRANCH_NAME" --label automation --json url -q '.[0].url') |
| 98 | + if [ -z "$PR_EXISTS" ]; then |
| 99 | + gh pr create \ |
| 100 | + --title "chore: update instrumentation list [automated]" \ |
| 101 | + --body "This PR was created automatically by the metadata update workflow." \ |
| 102 | + --head "$BRANCH_NAME" \ |
| 103 | + --base main |
| 104 | + echo "new_pr=true" >> $GITHUB_OUTPUT |
| 105 | + else |
| 106 | + echo "PR already exists: $PR_EXISTS" |
| 107 | + echo "new_pr=false" >> $GITHUB_OUTPUT |
| 108 | + fi |
| 109 | +
|
| 110 | + - name: Add label to PR |
| 111 | + if: steps.createpr.outputs.new_pr == 'true' |
| 112 | + env: |
| 113 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 114 | + run: | |
| 115 | + BRANCH_NAME="${{ steps.findbranch.outputs.branch }}" |
| 116 | + PR_URL=$(gh pr list --state open --head "$BRANCH_NAME" --json url -q '.[0].url') |
| 117 | + if [ -n "$PR_URL" ]; then |
| 118 | + gh pr edit "$PR_URL" --add-label "automation" --add-assignee jaydeluca |
| 119 | + else |
| 120 | + echo "No open PR found for branch $BRANCH_NAME." |
| 121 | + fi |
0 commit comments