Update contrib to the latest core source #395
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: 'Update contrib to the latest core source' | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "27 8 * * 5" # Run at 08:27 UTC on Fridays. | |
| permissions: | |
| contents: read | |
| jobs: | |
| update-otel: | |
| permissions: | |
| contents: write # required for pushing changes | |
| issues: write # required for creating failure issues | |
| runs-on: ubuntu-24.04 | |
| if: ${{ github.repository_owner == 'open-telemetry' }} | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 | |
| with: | |
| path: opentelemetry-collector-contrib | |
| - name: Pull the latest collector repo | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 | |
| with: | |
| path: opentelemetry-collector | |
| repository: open-telemetry/opentelemetry-collector | |
| - uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1 | |
| id: otelbot-token | |
| with: | |
| app-id: ${{ vars.OTELBOT_APP_ID }} | |
| private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }} | |
| - name: Prepare to update dependencies | |
| run: | | |
| exec > >(tee log.out) 2>&1 | |
| LAST_COMMIT="$(git -C ./opentelemetry-collector/ rev-parse HEAD)" | |
| cd opentelemetry-collector-contrib | |
| git config user.name otelbot | |
| git config user.email [email protected] | |
| branch="otelbot/update-otel-$(date +%s)" | |
| git checkout -b "$branch" | |
| make genotelcontribcol | |
| echo "LAST_COMMIT=$LAST_COMMIT" >> "$GITHUB_ENV" | |
| echo "BRANCH_NAME=$branch" >> "$GITHUB_ENV" | |
| env: | |
| GITHUB_TOKEN: ${{ steps.otelbot-token.outputs.token }} | |
| - name: Gets packages from links with retries | |
| uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 | |
| with: | |
| retry_wait_seconds: 1800 | |
| timeout_minutes: 120 | |
| max_attempts: 2 | |
| retry_on: error | |
| command: | | |
| cd opentelemetry-collector-contrib | |
| make update-otel OTEL_STABLE_VERSION=${{ env.LAST_COMMIT }} OTEL_VERSION=${{ env.LAST_COMMIT }} | |
| - name: Push and create PR | |
| run: | | |
| cd opentelemetry-collector-contrib | |
| git push --set-upstream origin ${{ env.BRANCH_NAME }} | |
| gh pr create --base main --title "[chore] Update core dependencies" --body "This PR updates the opentelemetry-collector modules to open-telemetry/opentelemetry-collector@${{ env.LAST_COMMIT }}" --draft | |
| env: | |
| GITHUB_TOKEN: ${{ steps.otelbot-token.outputs.token }} | |
| - name: File an issue if the workflow failed | |
| if: failure() | |
| run: | | |
| job_url="$(gh run view ${{ github.run_id }} -R ${{ github.repository }} --json jobs -q '.jobs[] | select(.name == "update-otel") | .url')" | |
| body="$(printf '[Link to job log](%s) | |
| <details> | |
| <summary>Last 100 lines of log</summary> | |
| ``` | |
| %s | |
| ``` | |
| </details>' "$job_url" "$(tail -n100 log.out | tail -c63K)")" | |
| gh issue create -R ${{ github.repository }} -t 'update-otel workflow failed' -b "$body" -l 'ci-cd' | |
| env: | |
| GH_TOKEN: ${{ github.token }} |