Created
March 29, 2025 15:45
-
-
Save mauro-balades/0c51ab82ab0b4059a28fb1129625ebe2 to your computer and use it in GitHub Desktop.
Close all issues on a repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
REPO=zen-browser/desktop | |
# bulk close issues | |
bulk_delete() { | |
# Get all (around 5k) issues that are open and paginated (NOT PULL REQUESTS) | |
raw_issues=$(gh api -X GET /repos/$REPO/issues --jq '.[] | select(.state == "open" and .pull_request == null) | .number' --paginate) | |
# hard code the issue numbers | |
issues_to_ignore=( 6302 37 ) | |
# Loop through each issue and check if it is in the ignore list | |
issues="" | |
for issue in $raw_issues; do | |
# Check if the issue is in the ignore list | |
if [[ ! " ${issues_to_ignore[@]} " =~ " ${issue} " ]]; then | |
issues+="$issue " | |
fi | |
done | |
# if there are no open issues, exit | |
if [[ -z "$issues" ]]; then | |
echo "No open issues found." | |
return 0 | |
fi | |
# Loop through each issue and close it | |
for issue in $issues; do | |
# close with a message | |
# get previous title | |
title=$(gh api -X GET /repos/$REPO/issues/$issue --jq '.title') | |
urlencode_title=$(echo "$title" | jq -sRr @uri) | |
issueURL="https://github.com/zen-browser/desktop/issues/new?template=bug_report.yml&title=$urlencode_title" | |
close_message=$'## Closing this issue as part of a repo cleanup\n\nDue to technical-debt we had in the past, we are currently clearing out old, duplicate, stale, and non-actionable issues to improve issue tracking and make it easier to focus on fixing real bugs.\n\nIf this issue is still relevant, please open a new issue using our updated issue template, which will help us categorize and address it more efficiently.\n\nThanks for your understanding and for helping us improve the project! 🚀\n\nThis issue can be reopened at: ' | |
final_message=$close_message"$issueURL" | |
gh issue close $issue --repo $REPO --comment "$final_message" | |
echo $issue >> ./closed_issues.txt | |
done | |
echo "All open issues have been closed." | |
} | |
bulk_delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment