Skip to content

Commit 73288bd

Browse files
committed
ci: guard empty BRANCH and deduplicate dist-dirty PR comment
- commit-dist: add explicit check after git branch -r derivation — if BRANCH is empty (shallow clone edge case or post-force-push race), fail with a clear error instead of a cryptic git error - comment-dist-dirty: use --edit-last so repeated fork PR pushes that consistently miss the dist/ update edit the existing bot comment instead of spamming new ones; fall back to a new comment if none exists
1 parent c893e28 commit 73288bd

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

.github/workflows/build-and-test.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ jobs:
113113
> git push
114114
> ```
115115
EOF
116+
gh pr comment "${{ github.event.pull_request.number }}" \
117+
--repo "${{ github.repository }}" \
118+
--body-file /tmp/comment.md \
119+
--edit-last || \
116120
gh pr comment "${{ github.event.pull_request.number }}" \
117121
--repo "${{ github.repository }}" \
118122
--body-file /tmp/comment.md
@@ -159,6 +163,10 @@ jobs:
159163
PR_HEAD=$(git rev-parse HEAD^2)
160164
BRANCH=$(git branch -r --contains "$PR_HEAD" --format='%(refname:short)' \
161165
| grep '^origin/' | grep -v 'origin/HEAD' | head -1 | sed 's|^origin/||')
166+
if [[ -z "$BRANCH" ]]; then
167+
echo "::error::Could not determine PR branch from git history."
168+
exit 1
169+
fi
162170
git checkout -B "$BRANCH" "origin/$BRANCH"
163171
cp -r /tmp/dist-artifact/. .github/actions/core/dist/
164172
git add .github/actions/core/dist/

0 commit comments

Comments
 (0)