Skip to content

Commit

Permalink
Possible Fix for 'close-discussion.yml' Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
og-mrk committed Jul 29, 2024
1 parent 4b9ebf7 commit 2c15bdf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/close-discussion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ 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:"
cat discussion_ids_list.txt
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"
Expand Down

0 comments on commit 2c15bdf

Please sign in to comment.