mirror of
https://github.com/navidrome/navidrome.git
synced 2026-05-03 06:51:16 +00:00
fix: deduplicate PR comments for modified migrations
Check if a warning comment already exists before posting a new one. This prevents duplicate comments when multiple commits are pushed to the PR.
This commit is contained in:
parent
ad8766b17a
commit
46cfdd4a65
11
.github/workflows/validate-migrations.sh
vendored
11
.github/workflows/validate-migrations.sh
vendored
@ -60,6 +60,16 @@ if [ -n "$MODIFIED_MIGRATIONS" ]; then
|
||||
|
||||
# Post a PR review comment if running in GitHub Actions with a PR
|
||||
if [ -n "$GITHUB_TOKEN" ] && [ -n "$GITHUB_REPOSITORY" ] && [ -n "$PR_NUMBER" ]; then
|
||||
# Check if a warning comment already exists to avoid duplicates
|
||||
EXISTING_COMMENT=$(curl -s \
|
||||
-H "Authorization: token $GITHUB_TOKEN" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \
|
||||
| jq -r '.[] | select(.body | startswith("### ⚠️ Modified Migration Files Detected")) | .id' | head -1)
|
||||
|
||||
if [ -n "$EXISTING_COMMENT" ]; then
|
||||
echo "Warning comment already exists (comment ID: $EXISTING_COMMENT), skipping"
|
||||
else
|
||||
COMMENT_BODY="### ⚠️ Modified Migration Files Detected
|
||||
|
||||
This PR modifies existing migration files that may have already been applied by users:
|
||||
@ -78,6 +88,7 @@ $(for m in $MODIFIED_MIGRATIONS; do echo "- \`$m\`"; done)
|
||||
echo "Posted PR comment about modified migrations"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$HAS_ERRORS" = "true" ]; then
|
||||
echo ""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user