File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -135,15 +135,31 @@ jobs:
135135 - name : Commit and push changes
136136 if : steps.check-exclusions.outputs.should-skip == 'false' && steps.update-changelog.outputs.changelog-updated == 'true'
137137 run : |
138+ set -euo pipefail
138139 BRANCH_NAME="${{ steps.check-existing-changelog-pr.outputs.changelog-pr-branch-name }}"
139140
140141 git add CHANGELOG.md
142+
143+ # Avoid failing when there's nothing new to commit
144+ if git diff --cached --quiet; then
145+ echo "No changelog changes to commit."
146+ exit 0
147+ fi
148+
141149 git commit -m "docs: update changelog for PR #${{ steps.update-changelog.outputs.pr-number }}"
142150
143- if [ "${{ steps.check-existing-changelog-pr.outputs.changelog-pr-exists }}" = "true" ]; then
144- git push origin $BRANCH_NAME
145- else
146- git push -u origin $BRANCH_NAME
151+ # Always sync latest remote branch tip before push
152+ git fetch origin "$BRANCH_NAME" || true
153+ if git show-ref --verify --quiet "refs/remotes/origin/$BRANCH_NAME"; then
154+ git rebase "origin/$BRANCH_NAME"
155+ fi
156+
157+ # Push and recover from race by rebasing once and retrying
158+ if ! git push origin "$BRANCH_NAME"; then
159+ echo "Push rejected, retrying after rebase..."
160+ git fetch origin "$BRANCH_NAME"
161+ git rebase "origin/$BRANCH_NAME"
162+ git push origin "$BRANCH_NAME"
147163 fi
148164
149165 - name : Create or update changelog PR
You can’t perform that action at this time.
0 commit comments