Skip to content

Instantly share code, notes, and snippets.

@timoguin
Created February 4, 2024 22:36
Show Gist options
  • Save timoguin/5bdc1b6ea417099dec5aa7e0038e10c0 to your computer and use it in GitHub Desktop.
Save timoguin/5bdc1b6ea417099dec5aa7e0038e10c0 to your computer and use it in GitHub Desktop.
Bulk add GitHub Issues to a GitHub Project
set -ex
# Use the GitHub CLI to loop through all repositories in an organization, get all the
# open issues, and add them to a single org-level project.
#
# Note: This was originally done with GNU Parallel but was refactored with a slower for
# loop due to hitting GitHub rate limits.
# Loop through list of repos
for repo in $(gh repo list tiki --json owner,name --jq '.[] | (.owner.login + "/" + .name)'); do
# Get list of issue URLs
issues=$(gh issue list --json url --state open --jq ".[].url" --repo $repo)
for issue in $issues; do
gh issue edit --add-project "TIKI Platform" $issue
sleep 2
done
# Add issues to the TIKI Platform projects
#
# NOTE: Doing it all in one call (w/ multiple URLs to the edit comment) caused a prioritization conflict:
# failed to update https://github.com/tiki/tiki-sdk-ios/issues/186: GraphQL: Prioritization The priority you are attempting to set for this record is not unique (add_000)
# gh issue edit --add-project "TIKI Platform" $issues
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment