@@ -23,24 +23,23 @@ jobs:
2323 with :
2424 repository : ${{ github.event.pull_request.head.repo.full_name }}
2525 ref : ${{ github.head_ref }}
26- token : ${{ secrets.GITHUB_TOKEN }}
26+ token : ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN || secrets. GITHUB_TOKEN }}
2727 fetch-depth : 0
2828
2929 - name : Install yq
3030 run : |
3131 go install github.com/mikefarah/yq/v4@v4.44.3
32- echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
3332
3433 - name : Check skip conditions
3534 id : skip
3635 env :
3736 PR_TITLE : ${{ github.event.pull_request.title }}
3837 PR_LABELS : ${{ toJson(github.event.pull_request.labels.*.name) }}
39- PR_ACTOR : ${{ github.actor }}
38+ PR_USER_LOGIN : ${{ github.event.pull_request.user.login }}
4039 run : |
4140 skip=false
4241
43- if [[ "$PR_ACTOR " == "dependabot[bot]" || "$PR_ACTOR " == "renovate[bot]" ]]; then
42+ if [[ "$PR_USER_LOGIN " == "dependabot[bot]" || "$PR_USER_LOGIN " == "renovate[bot]" ]]; then
4443 skip=true
4544 fi
4645
@@ -108,7 +107,7 @@ jobs:
108107 -H "Authorization: Bearer ${GITHUB_TOKEN}" \
109108 -d "$request_payload")"
110109
111- jq -r '.choices[0].message.content | fromjson' <<<"$response" | yq -P - > ".chloggen/pr-${PR_NUMBER}.yaml"
110+ jq -r '.choices[0].message.content | fromjson' <<<"$response" | "$(go env GOPATH)/bin/yq" -P - > ".chloggen/pr-${PR_NUMBER}.yaml"
112111
113112 - name : Validate AI Output
114113 if : ${{ steps.skip.outputs.skip != 'true' && steps.fragment.outputs.exists != 'true' && github.event.pull_request.head.repo.full_name == github.repository }}
@@ -117,10 +116,8 @@ jobs:
117116 run : |
118117 fragment=".chloggen/pr-${PR_NUMBER}.yaml"
119118
120- go install go.opentelemetry.io/build-tools/chloggen@v0.15.0
121- echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
122-
123- if ! chloggen validate --config .chloggen/config.yaml; then
119+ if ! "$(go env GOPATH)/bin/yq" -e 'has("change_type") and has("component") and has("note")' "$fragment" >/dev/null; then
120+ echo "missing required keys: change_type, component, note"
124121 rm -f "$fragment"
125122 exit 1
126123 fi
@@ -137,36 +134,6 @@ jobs:
137134 git commit -m "Add changelog fragment for PR #${PR_NUMBER}"
138135 git push origin HEAD:"${PR_BRANCH}"
139136
140- - name : Fork comment fallback
141- if : ${{ steps.skip.outputs.skip != 'true' && steps.fragment.outputs.exists != 'true' && github.event.pull_request.head.repo.full_name != github.repository }}
142- env :
143- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
144- PR_NUMBER : ${{ github.event.pull_request.number }}
145- run : |
146- {
147- echo "I could not generate a changelog fragment automatically because this pull request comes from a fork."
148- echo
149- echo "Please add the following file manually at .chloggen/pr-${PR_NUMBER}.yaml:"
150- echo
151- echo '```yaml'
152- printf '%s\n' \
153- '# Valid change types:' \
154- '# - breaking' \
155- '# - deprecation' \
156- '# - new_component' \
157- '# - enhancement' \
158- '# - bug_fix' \
159- 'change_type:' \
160- 'component:' \
161- 'note:' \
162- 'issues: []' \
163- 'subtext:' \
164- 'change_logs: [user]'
165- echo '```'
166- } > /tmp/changelog-comment.md
167-
168- gh pr comment --repo "${{ github.repository }}" "${PR_NUMBER}" --body-file /tmp/changelog-comment.md
169-
170137 validate-fragment :
171138 needs : generate-fragment
172139 if : always()
@@ -176,19 +143,19 @@ jobs:
176143 with :
177144 repository : ${{ github.event.pull_request.head.repo.full_name }}
178145 ref : ${{ github.head_ref }}
179- token : ${{ secrets.GITHUB_TOKEN }}
146+ token : ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN || secrets. GITHUB_TOKEN }}
180147 fetch-depth : 0
181148
182149 - name : Check skip conditions
183150 id : skip
184151 env :
185152 PR_TITLE : ${{ github.event.pull_request.title }}
186153 PR_LABELS : ${{ toJson(github.event.pull_request.labels.*.name) }}
187- PR_ACTOR : ${{ github.actor }}
154+ PR_USER_LOGIN : ${{ github.event.pull_request.user.login }}
188155 run : |
189156 skip=false
190157
191- if [[ "$PR_ACTOR " == "dependabot[bot]" || "$PR_ACTOR " == "renovate[bot]" ]]; then
158+ if [[ "$PR_USER_LOGIN " == "dependabot[bot]" || "$PR_USER_LOGIN " == "renovate[bot]" ]]; then
192159 skip=true
193160 fi
194161
@@ -207,7 +174,6 @@ jobs:
207174 run : exit 0
208175
209176 - name : Validate fragment
210- if : ${{ steps.skip.outputs.skip != 'true' }}
211177 env :
212178 PR_NUMBER : ${{ github.event.pull_request.number }}
213179 run : |
@@ -219,5 +185,4 @@ jobs:
219185 fi
220186
221187 go install go.opentelemetry.io/build-tools/chloggen@v0.15.0
222- echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
223- chloggen validate --config .chloggen/config.yaml
188+ "$(go env GOPATH)/bin/chloggen" validate --config .chloggen/config.yaml
0 commit comments