Skip to content

Auto-update OpenTelemetry Extension #1751

Auto-update OpenTelemetry Extension

Auto-update OpenTelemetry Extension #1751

name: Auto-update OpenTelemetry Extension
on:
schedule:
# hourly at minute 46
- cron: "46 * * * *"
workflow_dispatch:
permissions:
contents: write
jobs:
check-versions:
runs-on: ubuntu-latest
outputs:
current-version: ${{ steps.check-versions.outputs.current-version }}
latest-version: ${{ steps.check-versions.outputs.latest-version }}
already-opened: ${{ steps.check-versions.outputs.already-opened }}
steps:
- uses: actions/checkout@v4
- id: check-versions
name: Check versions
env:
GH_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
run: |
current_version=$(grep -Po "opentelemetryJavaagent : \"\K[0-9]+.[0-9]+.[0-9]+" build.gradle)
latest_version=$(gh release view \
--repo open-telemetry/opentelemetry-java-instrumentation \
--json tagName \
--jq .tagName \
| sed 's/^v//')
matches=$(gh pr list \
--author openinsightbot \
--state open \
--search "in:title \"Update the OpenTelemetry Java Instrumentation Extension version to $latest_version\"")
if [ ! -z "$matches" ]
then
already_opened=true
fi
echo "current-version=$current_version" >> $GITHUB_OUTPUT
echo "latest-version=$latest_version" >> $GITHUB_OUTPUT
echo "already-opened=$already_opened" >> $GITHUB_OUTPUT
update-otel-extension:
runs-on: ubuntu-latest
if: |
needs.check-versions.outputs.current-version != needs.check-versions.outputs.latest-version &&
needs.check-versions.outputs.already-opened != 'true'
needs:
- check-versions
steps:
- uses: actions/checkout@v4
- name: Update version
env:
VERSION: ${{ needs.check-versions.outputs.latest-version }}
run: |
chmod -R 777 ./.github/scripts/update-version.sh
./.github/scripts/update-version.sh $VERSION
# - name: Use CLA approved github bot
# run: .github/scripts/use-cla-approved-github-bot.sh
#
# - name: Free disk space
# run: .github/scripts/gha-free-disk-space.sh
# - name: Update license report
# uses: gradle/gradle-build-action@v2
# with:
# arguments: generateLicenseReport
#
# - name: Undo license report clean
# if: failure()
# run: git checkout -- licenses
- name: Create pull request against main
if: success() || failure()
env:
VERSION: ${{ needs.check-versions.outputs.latest-version }}
# not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows
GH_TOKEN: ${{ secrets.ACTIONS_TOKEN }}
run: |
message="Update the OpenTelemetry otel extension version to $VERSION"
body="Update the OpenTelemetry otel extension version to \`$VERSION\`."
branch="openinsightbot/update-opentelemetry-extension-to-${VERSION}"
git config user.name 'openinsightbot'
git config user.email 'openinsightbot@users.noreply.github.com'
git checkout -b $branch
git commit -a -m "$message"
git push --set-upstream origin $branch
gh pr create --title "$message" \
--body "$body" \
--base main