Skip to content

Commit f4aabbb

Browse files
committed
fix: address remaining review findings
- Add git fetch before branch checkout (shallow clone has no branch refs) - Handle partial fix case: report remaining errors when fixes are pushed - Handle skipped steps: detect when earlier steps fail and report accurately - Rename job ID from fix-changelogs to update-changelogs for consistency
1 parent 61a4b9e commit f4aabbb

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

.github/workflows/update-changelogs.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3535
PR_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }}
3636

37-
fix-changelogs:
37+
update-changelogs:
3838
name: Update changelogs
3939
needs: is-fork-pull-request
4040
if: ${{ needs.is-fork-pull-request.outputs.IS_FORK == 'false' }}
@@ -66,9 +66,11 @@ jobs:
6666
node-version: 22.x
6767
ref: ${{ steps.pr.outputs.sha }}
6868

69-
# Checkout by branch name so validate-changelog.sh can detect release branches
70-
- name: Checkout branch by name
71-
run: git checkout "$PR_REF"
69+
# Fetch and checkout by branch name so git push targets the correct branch
70+
- name: Checkout PR branch
71+
run: |
72+
git fetch origin "$PR_REF"
73+
git checkout "$PR_REF"
7274
env:
7375
PR_REF: ${{ steps.pr.outputs.ref }}
7476

@@ -99,12 +101,16 @@ jobs:
99101
- name: Comment result
100102
if: always()
101103
run: |
102-
if [ "$CHANGED" = "true" ]; then
104+
if [ "$CHANGED" = "true" ] && [ "$VALIDATE_OUTCOME" = "failure" ]; then
105+
gh pr comment "$PR_NUMBER" --body "Changelogs updated and pushed, but some validation errors remain. Check the [workflow run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) for details."
106+
elif [ "$CHANGED" = "true" ]; then
103107
gh pr comment "$PR_NUMBER" --body "Changelogs updated and pushed."
104108
elif [ "$COMMIT_OUTCOME" = "failure" ]; then
105109
gh pr comment "$PR_NUMBER" --body "Failed to push changelog fixes. Check the [workflow run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) for details."
106110
elif [ "$VALIDATE_OUTCOME" = "failure" ]; then
107111
gh pr comment "$PR_NUMBER" --body "Changelog validation failed. Check the [workflow run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) for details."
112+
elif [ "$VALIDATE_OUTCOME" = "skipped" ] || [ "$COMMIT_OUTCOME" = "skipped" ]; then
113+
gh pr comment "$PR_NUMBER" --body "Workflow failed before changelog validation. Check the [workflow run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) for details."
108114
else
109115
gh pr comment "$PR_NUMBER" --body "No changelog changes needed."
110116
fi

0 commit comments

Comments
 (0)