You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if [[ -n "$missing_links" || -n "$extra_links" ]]; then
comment_text+="Issues referenced in commit messages and issues linked to this PR are not in sync."
fi
if [[ -n "$missing_links" ]]; then
comment_text+="\nPlease manually link this PR to the following issues: $missing_links"
fi
if [[ -n "$extra_links" ]]; then
comment_text+="\nPlease manually unlink this PR from the following issues or reference the issues in a commit message: $extra_links"
fi
if [[ -n "$comment_text" ]]; then
echo $comment_text
# Export the comment text as an environment variable.
echo "COMMENT_TEXT=$comment_text" >> $GITHUB_ENV
else
echo "Issues referenced in commit messages and issues linked to this PR are in sync."
fi
- name: Add PR comment
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Fetch all previous comments of this check. Other workflows also comment as this bot, so
# select the comments by their first sentence.
existing_comments=$(gh api --paginate "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" --jq '.[] | select(.user.login == "github-actions[bot]" and (.body | startswith("Issues referenced in commit messages and issues linked to this PR are not in sync."))) | .id')
echo "existing comments: $existing_comments"
# Delete existing comments from this bot.
for comment_id in $existing_comments; do
echo "Deleting comment ID $comment_id"
gh api --method DELETE "repos/${{ github.repository }}/issues/comments/$comment_id"