Skip to content

Commit

Permalink
update to versioned branch
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Jan 29, 2025
1 parent 7aac296 commit 515595b
Showing 1 changed file with 65 additions and 6 deletions.
71 changes: 65 additions & 6 deletions .github/workflows/update-semconv-integration-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,50 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: integration/semantic-conventions
# this is needed in order to do rebase below
# this is needed in order to do the rebase belo
fetch-depth: 0
# this is needed in order to trigger workflows on the PR
# this is needed in order to trigger workflows when pushing new commits to the PR
token: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}

- name: Look for an existing branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=$(git branch -r \
| grep '^ *origin/opentelemetrybot/semantic-conventions-v[0-9]+\.[0-9]+\.[0-9]+$' \
| sed 's/ *origin\/opentelemetrybot\/semantic-conventions-//')
if [[ -z "$versions" ]]; then
latest_version=$(gh release view \
--repo open-telemetry/semantic-conventions \
--json tagName \
--jq .tagName)
if [[ $latest_version =~ ^v([0-9]+)\.([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=opentelemetrybot/semantic-conventions-${version}" >> $GITHUB_ENV
- name: Create or checkout branch if needed
run: |
if ! git ls-remote --exit-code --heads origin $BRANCH; then
echo here1
git checkout -b $BRANCH origin/main
echo here2
git push -u origin $BRANCH
echo here3
else
echo here4
git checkout $BRANCH
fi
- name: Use CLA approved github bot
run: |
git config user.name opentelemetrybot
Expand All @@ -30,13 +68,34 @@ jobs:
git fetch origin
git merge origin/main
if [ "$(git rev-parse HEAD)" != "$previous" ]; then
git push origin integration/semantic-conventions
git push
fi
- name: Update submodule
run: |
git submodule update --init --remote content-modules/semantic-conventions
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
else
git reset --hard origin/main
fi
cd ../..
if ! git diff-index --quiet HEAD; then
git commit -am "Update submodule"
git push origin integration/semantic-conventions
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: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
run: |
prs=$(gh pr list --state open --head $BRANCH)
if [ -z "$prs" ]; then
gh pr create --title "Update semantic conventions to ${VERSION}" \
--body "This PR updates the semantic conventions to ${VERSION}."
fi

0 comments on commit 515595b

Please sign in to comment.