forked from open-telemetry/opentelemetry-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (94 loc) · 3.77 KB
/
generate-semantic-conventions-pr.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Generate Semantic Conventions PR
on:
schedule:
# Daily at 01:30 (UTC)
- cron: "30 1 * * *"
workflow_dispatch:
permissions:
contents: read
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- id: check-versions
name: Check versions
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
latest_version=v$(gh release view \
--repo open-telemetry/semantic-conventions \
--json tagName \
--jq .tagName \
| sed 's/^v//')
found=$(find semconv -name $latest_version)
if [[ $found =~ $latest_version ]]; 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:
permissions:
contents: write # for Git to git push
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Checkout semantic-convention
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: open-telemetry/semantic-conventions
path: tmp-semantic-conventions
fetch-depth: 0
- 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 [email protected]
- 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\`. Related to #10842"
branch="opentelemetrybot/add-semantic-conventions-${VERSION}"
git checkout -b $branch
git add semconv/
# 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: [10842]
EOF
git add .chloggen/semconv-$VERSION.yaml
git commit -m "$message"
git push --set-upstream origin $branch
url=$(gh pr create --title "$message" \
--body "$body" \
--base main)
pull_request_number=${url//*\//}