Update semconv integration branch #69
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 semconv integration branch | |
| on: | |
| schedule: | |
| # daily at 10:24 UTC | |
| - cron: '24 10 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| update-semconv-integration-branch: | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'open-telemetry/opentelemetry.io' | |
| steps: | |
| - uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1 | |
| id: otelbot-token | |
| with: | |
| # the higher privileged docs token is needed to push commits to an existing PR | |
| app-id: ${{ vars.OTELBOT_DOCS_APP_ID }} | |
| private-key: ${{ secrets.OTELBOT_DOCS_PRIVATE_KEY }} | |
| - uses: actions/checkout@v6 | |
| with: | |
| # this is needed to do the rebase below | |
| fetch-depth: 0 | |
| # this is needed to trigger workflows when pushing new commits to an existing PR | |
| token: ${{ steps.otelbot-token.outputs.token }} | |
| - name: Set environment variables | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| branch_prefix="otelbot/semconv-integration" | |
| version=$(git branch -r \ | |
| | grep -E "^ *origin/$branch_prefix-v[0-9]+\.[0-9]+\..*-dev" \ | |
| | sed "s|^ *origin/$branch_prefix-||" \ | |
| | sed "s|-dev$||") | |
| if [[ -z "$version" ]]; then | |
| latest_version=$(gh release view \ | |
| --repo open-telemetry/semantic-conventions \ | |
| --json tagName \ | |
| --jq .tagName) | |
| if [[ $latest_version =~ ^v([0-9]+)\.([0-9]+)\. ]]; then | |
| major="${BASH_REMATCH[1]}" | |
| minor="${BASH_REMATCH[2]}" | |
| version="v$major.$((minor + 1)).0" | |
| else | |
| echo "unexpected version: $latest_version" | |
| exit 1 | |
| fi | |
| fi | |
| echo "VERSION=$version" >> $GITHUB_ENV | |
| echo "BRANCH=$branch_prefix-$version-dev" >> $GITHUB_ENV | |
| - name: Checkout or create branch | |
| run: | | |
| if ! git ls-remote --exit-code --heads origin $BRANCH; then | |
| git checkout -b $BRANCH origin/main | |
| git push -u origin $BRANCH | |
| else | |
| git checkout $BRANCH | |
| fi | |
| - name: Use CLA approved github bot | |
| run: | | |
| git config user.name otelbot | |
| git config user.email 197425009+otelbot@users.noreply.github.com | |
| - name: Merge from main | |
| run: | | |
| previous=$(git rev-parse HEAD) | |
| git fetch origin | |
| git merge origin/main | |
| if [ "$(git rev-parse HEAD)" != "$previous" ]; then | |
| git push | |
| fi | |
| - name: Update submodule and Hugo mounts | |
| run: | | |
| git submodule update --init content-modules/semantic-conventions | |
| cd content-modules/semantic-conventions | |
| if git ls-remote --exit-code --tags origin $VERSION; then | |
| git reset --hard $VERSION | |
| tag_exists=true | |
| else | |
| git reset --hard origin/main | |
| fi | |
| commit_desc=$(git describe --tags) | |
| cd ../.. | |
| sed -i "s/^\tsemconv-pin = .*/\tsemconv-pin = $commit_desc/" .gitmodules | |
| if [ "$tag_exists" == "true" ]; then | |
| sed -i "s/^\(\s *\)semconv: .*/\1semconv: ${commit_desc#v}/" scripts/content-modules/adjust-pages.pl | |
| fi | |
| ./scripts/update-semconv-mounts.pl | |
| git add -A | |
| if ! git diff-index --quiet --cached HEAD; then | |
| git commit -am "Update semconv submodule to $commit_desc" | |
| git push | |
| fi | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| - name: Update refcache | |
| run: | | |
| npm install --omit=optional | |
| # Ignore link-check failures so we can still commit refcache updates | |
| npm run fix:refcache || true | |
| # Prune 404 entries, if any | |
| npm run _refcache:prune | |
| git add -A | |
| if ! git diff-index --quiet --cached HEAD; then | |
| git commit -am "Update refcache" | |
| git push | |
| fi | |
| - name: Create pull request if needed | |
| env: | |
| # not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows | |
| GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} | |
| run: | | |
| prs=$(gh pr list --state open --head $BRANCH) | |
| if [ -z "$prs" ]; then | |
| gh pr create --title "DRAFT Update semantic conventions to unreleased $VERSION-dev" \ | |
| --body "This is a draft PR used for identifying issues integrating the latest (unreleased) semantic conventions." \ | |
| --draft | |
| fi |