@@ -17,7 +17,6 @@ permissions:
1717
1818jobs :
1919 generate-fragment :
20- if : ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' }}
2120 runs-on : ubuntu-latest
2221 steps :
2322 - uses : actions/checkout@v4
@@ -27,15 +26,25 @@ jobs:
2726 token : ${{ secrets.GITHUB_TOKEN }}
2827 fetch-depth : 0
2928
29+ - name : Install yq
30+ run : |
31+ go install github.com/mikefarah/yq/v4@v4.44.3
32+ echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
33+
3034 - name : Check skip conditions
3135 id : skip
3236 env :
3337 PR_TITLE : ${{ github.event.pull_request.title }}
3438 PR_LABELS : ${{ toJson(github.event.pull_request.labels.*.name) }}
39+ PR_ACTOR : ${{ github.actor }}
3540 run : |
3641 skip=false
3742
38- if [[ $PR_TITLE == \[chore\]* ]]; then
43+ if [[ "$PR_ACTOR" == "dependabot[bot]" || "$PR_ACTOR" == "renovate[bot]" ]]; then
44+ skip=true
45+ fi
46+
47+ if [[ "$PR_TITLE" == \[chore\]* ]]; then
3948 skip=true
4049 fi
4150
@@ -58,18 +67,12 @@ jobs:
5867 echo "exists=false" >> "$GITHUB_OUTPUT"
5968 fi
6069
61- - name : Install yq
62- if : ${{ steps.skip.outputs.skip != 'true' && steps.fragment.outputs.exists != 'true' && github.event.pull_request.head.repo.full_name == github.repository }}
63- run : |
64- go install github.com/mikefarah/yq/v4@latest
65- echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
66-
6770 - name : Fetch base branch
6871 if : ${{ steps.skip.outputs.skip != 'true' && steps.fragment.outputs.exists != 'true' && github.event.pull_request.head.repo.full_name == github.repository }}
6972 run : |
7073 git fetch origin "${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}" --depth=1
7174
72- - name : Generate changelog fragment from GitHub Models
75+ - name : Generate fragment
7376 if : ${{ steps.skip.outputs.skip != 'true' && steps.fragment.outputs.exists != 'true' && github.event.pull_request.head.repo.full_name == github.repository }}
7477 env :
7578 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
9093 messages: [
9194 {
9295 role: "system",
93- content: "Generate a single JSON object for a changelog fragment. Return only valid JSON with these keys: change_type, component, note, issues, subtext, change_logs. change_type must be one of breaking, deprecation, new_component, enhancement, bug_fix. component must be a concise repository component or area such as jmx-metrics . note must be a brief end-user facing summary. issues must be an array of issue numbers without #. subtext is optional and may be null or omitted. change_logs must be [\"user\"]. Do not add markdown or extra keys."
96+ content: "Generate a single JSON object for a changelog fragment. Return only valid JSON with these keys: change_type, component, note, issues, subtext, change_logs. change_type must be one of breaking, deprecation, new_component, enhancement, bug_fix. component must be blank if the PR does not clearly map to one component . note must be a brief end-user facing summary. issues must be an array of issue numbers without #. subtext is optional and may be null or omitted. change_logs must be [\"user\"]. Do not add markdown or extra keys."
9497 },
9598 {
9699 role: "user",
@@ -99,14 +102,30 @@ jobs:
99102 ]
100103 }')"
101104
102- response="$(curl --fail-with-body --silent --show-error https://models.inference.ai.azure.com/chat/completions \
105+ response="$(curl --fail-with-body --silent --show-error https://models.github.ai/inference/chat/completions \
106+ -H "Accept: application/vnd.github+json" \
103107 -H "Content-Type: application/json" \
104108 -H "Authorization: Bearer ${GITHUB_TOKEN}" \
105109 -d "$request_payload")"
106110
107111 jq -r '.choices[0].message.content | fromjson' <<<"$response" | yq -P - > ".chloggen/pr-${PR_NUMBER}.yaml"
108112
109- - name : Commit changelog fragment
113+ - name : Validate AI Output
114+ if : ${{ steps.skip.outputs.skip != 'true' && steps.fragment.outputs.exists != 'true' && github.event.pull_request.head.repo.full_name == github.repository }}
115+ env :
116+ PR_NUMBER : ${{ github.event.pull_request.number }}
117+ run : |
118+ fragment=".chloggen/pr-${PR_NUMBER}.yaml"
119+
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
124+ rm -f "$fragment"
125+ exit 1
126+ fi
127+
128+ - name : Commit
110129 if : ${{ steps.skip.outputs.skip != 'true' && steps.fragment.outputs.exists != 'true' && github.event.pull_request.head.repo.full_name == github.repository }}
111130 env :
112131 PR_NUMBER : ${{ github.event.pull_request.number }}
@@ -118,7 +137,7 @@ jobs:
118137 git commit -m "Add changelog fragment for PR #${PR_NUMBER}"
119138 git push origin HEAD:"${PR_BRANCH}"
120139
121- - name : Ask fork contributors to add a fragment manually
140+ - name : Fork comment fallback
122141 if : ${{ steps.skip.outputs.skip != 'true' && steps.fragment.outputs.exists != 'true' && github.event.pull_request.head.repo.full_name != github.repository }}
123142 env :
124143 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -138,15 +157,15 @@ jobs:
138157 '# - enhancement' \
139158 '# - bug_fix' \
140159 'change_type:' \
141- 'component: jmx-metrics ' \
160+ 'component:' \
142161 'note:' \
143162 'issues: []' \
144163 'subtext:' \
145164 'change_logs: [user]'
146165 echo '```'
147166 } > /tmp/changelog-comment.md
148167
149- gh pr comment "${PR_NUMBER}" --body-file /tmp/changelog-comment.md
168+ gh pr comment --repo "${{ github.repository }}" "${PR_NUMBER}" --body-file /tmp/changelog-comment.md
150169
151170 validate-fragment :
152171 needs : generate-fragment
@@ -165,10 +184,15 @@ jobs:
165184 env :
166185 PR_TITLE : ${{ github.event.pull_request.title }}
167186 PR_LABELS : ${{ toJson(github.event.pull_request.labels.*.name) }}
187+ PR_ACTOR : ${{ github.actor }}
168188 run : |
169189 skip=false
170190
171- if [[ $PR_TITLE == \[chore\]* ]]; then
191+ if [[ "$PR_ACTOR" == "dependabot[bot]" || "$PR_ACTOR" == "renovate[bot]" ]]; then
192+ skip=true
193+ fi
194+
195+ if [[ "$PR_TITLE" == \[chore\]* ]]; then
172196 skip=true
173197 fi
174198
@@ -178,13 +202,11 @@ jobs:
178202
179203 echo "skip=$skip" >> "$GITHUB_OUTPUT"
180204
181- - name : Install chloggen
182- if : ${{ steps.skip.outputs.skip != 'true' }}
183- run : |
184- go install go.opentelemetry.io/build-tools/chloggen@latest
185- echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
205+ - name : Exit if skipped
206+ if : ${{ steps.skip.outputs.skip == 'true' }}
207+ run : exit 0
186208
187- - name : Verify changelog fragment
209+ - name : Validate fragment
188210 if : ${{ steps.skip.outputs.skip != 'true' }}
189211 env :
190212 PR_NUMBER : ${{ github.event.pull_request.number }}
@@ -196,4 +218,6 @@ jobs:
196218 exit 1
197219 fi
198220
221+ go install go.opentelemetry.io/build-tools/chloggen@v0.15.0
222+ echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
199223 chloggen validate --config .chloggen/config.yaml
0 commit comments