mirror of
https://github.com/github/awesome-copilot.git
synced 2026-07-16 02:43:24 +00:00
Fix contributor reputation check comment deduping (#2150)
* Fix contributor check comment upsert behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -192,17 +192,22 @@ jobs:
|
|||||||
profile="${{ steps.results.outputs.profile }}"
|
profile="${{ steps.results.outputs.profile }}"
|
||||||
cred="${{ steps.results.outputs.credential }}"
|
cred="${{ steps.results.outputs.credential }}"
|
||||||
marker="<!-- agt-contributor-check -->"
|
marker="<!-- agt-contributor-check -->"
|
||||||
comment_id=$(
|
comment_ids=$(
|
||||||
gh api "repos/${{ github.repository }}/issues/$number/comments" --paginate \
|
gh api "repos/${{ github.repository }}/issues/$number/comments" --paginate \
|
||||||
--arg marker "$marker" \
|
--arg marker "$marker" \
|
||||||
--jq '.[] | select(.user.login == "github-actions[bot]" and (.body | contains($marker))) | .id' \
|
--jq '.[] | select(.user.login == "github-actions[bot]" and ((.body // "") | contains($marker))) | .id'
|
||||||
| head -n 1
|
|
||||||
)
|
)
|
||||||
|
comment_id=$(printf "%s\n" "$comment_ids" | sed -n '1p')
|
||||||
|
|
||||||
if [ "$risk" != "MEDIUM" ] && [ "$risk" != "HIGH" ]; then
|
if [ "$risk" != "MEDIUM" ] && [ "$risk" != "HIGH" ]; then
|
||||||
if [ -n "$comment_id" ]; then
|
if [ -n "$comment_id" ]; then
|
||||||
gh api --method DELETE "repos/${{ github.repository }}/issues/comments/$comment_id" \
|
# Keep one canonical comment thread by removing all matching comments
|
||||||
|| echo "Comment $comment_id could not be deleted; continuing because the comment may have already been removed or changed."
|
# when risk drops below MEDIUM.
|
||||||
|
while IFS= read -r id; do
|
||||||
|
[ -z "$id" ] && continue
|
||||||
|
gh api --method DELETE "repos/${{ github.repository }}/issues/comments/$id" \
|
||||||
|
|| echo "Comment $id could not be deleted; continuing because the comment may have already been removed or changed."
|
||||||
|
done <<< "$comment_ids"
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@@ -226,6 +231,11 @@ jobs:
|
|||||||
|
|
||||||
if [ -n "$comment_id" ]; then
|
if [ -n "$comment_id" ]; then
|
||||||
gh api --method PATCH "repos/${{ github.repository }}/issues/comments/$comment_id" -f body="$body"
|
gh api --method PATCH "repos/${{ github.repository }}/issues/comments/$comment_id" -f body="$body"
|
||||||
|
# Clean up any stale duplicates after updating the canonical comment.
|
||||||
|
printf "%s\n" "$comment_ids" | sed '1d' | while IFS= read -r id; do
|
||||||
|
[ -z "$id" ] && continue
|
||||||
|
gh api --method DELETE "repos/${{ github.repository }}/issues/comments/$id" >/dev/null 2>&1 || true
|
||||||
|
done
|
||||||
else
|
else
|
||||||
gh api --method POST "repos/${{ github.repository }}/issues/$number/comments" -f body="$body"
|
gh api --method POST "repos/${{ github.repository }}/issues/$number/comments" -f body="$body"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user