forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] add github action to generate semconv pr (open-telemetry#9064)
This is similar to the workflow used by the jmx gatherer PR in the collector contrib repo. --------- Signed-off-by: Alex Boten <aboten@lightstep.com>
- Loading branch information
Alex Boten
authored
Dec 12, 2023
1 parent
52fed05
commit 6d5b45f
Showing
1 changed file
with
107 additions
and
0 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
.github/workflows/generate-semantic-conventions-pr.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Generate Semantic Conventions PR | ||
|
||
on: | ||
schedule: | ||
# Daily at 01:30 (UTC) | ||
- cron: '30 1 * * *' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check-versions: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
latest-version: ${{ steps.check-versions.outputs.latest-version }} | ||
already-added: ${{ steps.check-versions.outputs.already-added }} | ||
already-opened: ${{ steps.check-versions.outputs.already-opened }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- id: check-versions | ||
name: Check versions | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# version in this repo are prefixed with v | ||
latest_version=v$(gh release view \ | ||
--repo open-telemetry/semantic-conventions \ | ||
--json tagName \ | ||
--jq .tagName \ | ||
| sed 's/^v//') | ||
rc=$(find semconv -name $latest_version | grep .) | ||
if $rc == 0; then | ||
already_added=true | ||
fi | ||
matches=$(gh pr list \ | ||
--author opentelemetrybot \ | ||
--state open \ | ||
--search "in:title \"Add semantic conventions version $latest_version\"") | ||
if [ ! -z "$matches" ] | ||
then | ||
already_opened=true | ||
fi | ||
echo "latest-version=$latest_version" >> $GITHUB_OUTPUT | ||
echo "already-added=$already_added" >> $GITHUB_OUTPUT | ||
echo "already-opened=$already_opened" >> $GITHUB_OUTPUT | ||
update-semantic-conventions: | ||
runs-on: ubuntu-latest | ||
if: | | ||
needs.check-versions.outputs.already-added != 'true' && | ||
needs.check-versions.outputs.already-opened != 'true' | ||
needs: | ||
- check-versions | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Checkout semantic-convention | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: open-telemetry/semantic-convention | ||
path: tmp-semantic-conventions | ||
|
||
- name: Update version | ||
env: | ||
VERSION: ${{ needs.check-versions.outputs.latest-version }} | ||
run: | | ||
make gensemconv SPECPATH=./tmp-semantic-conventions SPECTAG=$VERSION | ||
git diff | ||
- name: Use CLA approved github bot | ||
run: | | ||
git config user.name opentelemetrybot | ||
git config user.email 107717825+opentelemetrybot@users.noreply.github.com | ||
- name: Create pull request against main | ||
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.OPENTELEMETRYBOT_GITHUB_TOKEN }} | ||
run: | | ||
message="Add semantic conventions version $VERSION" | ||
body="Add semantic conventions version \`$VERSION\`." | ||
branch="opentelemetrybot/add-semantic-conventions-${VERSION}" | ||
git checkout -b $branch | ||
git add semconv/ | ||
git commit -m "$message" | ||
git push --set-upstream origin $branch | ||
url=$(gh pr create --title "$message" \ | ||
--body "$body" \ | ||
--base main) | ||
pull_request_number=${url//*\//} | ||
# see the template for change log entry file at blob/main/.chloggen/TEMPLATE.yaml | ||
cat > .chloggen/semconv-$VERSION.yaml << EOF | ||
change_type: enhancement | ||
component: semconv | ||
note: Add semantic conventions version $VERSION | ||
issues: [ $pull_request_number ] | ||
EOF | ||
git add .chloggen/semconv-$VERSION.yaml | ||
git commit -m "Add change log entry" | ||
git push |