Skip to content

Instantly share code, notes, and snippets.

@vincenthz
Created September 20, 2023 07:22
Show Gist options
  • Save vincenthz/3fcc8218f20aad42542c31f7dae39593 to your computer and use it in GitHub Desktop.
Save vincenthz/3fcc8218f20aad42542c31f7dae39593 to your computer and use it in GitHub Desktop.
close all issues, PRs and archive a repository on github
#!/bin/sh
#
# Close all issues, PR, and archive a repository
if [ $# -ne 1 ]; then
echo "usage: $0 <github-repository>"
exit 1
fi
REPO=$1
echo "# archiving repository $REPO"
echo "-> closing issues ..."
for issue in $(gh issue list --state open -R ${REPO} --json number --jq '.[].number')
do
gh issue close -R ${REPO} ${issue} -r "not planned"
done
echo "-> closing PRs ..."
for pr in $(gh pr list --state open -R ${REPO} --json number --jq '.[].number')
do
gh pr close -R ${REPO} -c "archiving repository" $pr
done
echo "-> archiving ..."
gh repo archive $REPO -y
echo "=> done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment