diff --git a/.github/workflows/close-discussion.yaml b/.github/workflows/close-discussion.yaml index cbb0e34c71..2d86344523 100644 --- a/.github/workflows/close-discussion.yaml +++ b/.github/workflows/close-discussion.yaml @@ -22,8 +22,16 @@ jobs: discussion_ids_arr=() cat pr_body.txt | grep -i -Po '^\s*(-|\d+\.)?\s*(Resolve(s|d)?)\s*#\d+\s*$|^\s*(-|\d+\.)?\s*(Fix(es|ed)?)\s*#\d+\s*$|^\s*(-|\d+\.)?\s*(Close(s|d)?)\s*#\d+\s*$' | awk -F '#' '{print $2}' > discussion_ids_list.txt - while read -r line; do discussion_ids_arr+=("$line"); done < discussion_ids_list.txt + if [ -s discussion_ids_list.txt ]; then + while read -r line; do discussion_ids_arr+=("$line"); done < discussion_ids_list.txt + else + echo "Found no IDs for discussions, or any linked item, quitting..." + exit 0 + fi + number_of_ids=${#discussion_ids_arr[@]} + + # Print some debug info echo "Number of IDs: ${number_of_id}" echo "IDs Array: ${discussion_ids_arr[@]}" echo "IDs List:" @@ -31,7 +39,6 @@ jobs: for (( i=0; i<${number_of_ids}; i++ )); do discussion_id=${discussion_ids_arr[$i]} - echo "$discussion_id" curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" \ -d '{"state": "closed"}' \ "https://api.github.com/repos/${{ github.repository }}/discussions/$discussion_id"