I’m currently trying to migrate a load of Github issues into the new Github projects system
Unfortunately, they do not make this easy via the web interface. There is though the CLI client which seems eminently scriptable, so this is my findings as I explore this approach.
First you need to install the client and authenticate with the command
gh auth login
First thing you might notice is that the gh client output is full of fancy colours. This is nice from a UI point of view, but makes scripting more difficult. We can get around it easily by piping through
gh search issues --state open --repo "LongTermSupport/lxc-bash" | cat
Another thing you might notice is that args are in long form with leading
-- but they do not include an
= sign. A simple gotcha that caught me out at first.
Pulling out issue IDs for scripting
You can cd into a repo folder and use
gh issue list to get a list of issues in that repo. Chances are though, you need to search for specific issues by state, project, etc. The best way to do this is using
This snippet will pull out the issue IDs on their own:
gh search issues \ --state open \ --repo "LongTermSupport/lxc-bash" \ --limit 1000 \ | cat \ | cut -d ' ' -f 2
This snippet runs the Github search, then it is piped through
cat to strip out colors and fancy formatting. Finally we use
cut to pull out the numeric ID.
Updating the Project
Our next mission is to use a BASH loop to update the issues that we have found. If you are using the legacy projects in Github, the ones that are tied to a specific repo, then this loop should work for you:
for issueId in $(gh search issues \ --state open \ --repo "LongTermSupport/lxc-bash" \ --limit 1000 \ | cat \ | cut -d ' ' -f 2 ); do echo "Issue ID: $issueId" set -x gh issue edit $issueId --add-project "project-name" set +x echo "EXITING AFTER FIRST ISSUE FOR TESTING" exit 1 done ~
This runs the previous gh client search and pulls out the ID, then it will loop through the IDs and run an
edit command to add the project.
Gotcha: You can’t use gh client to work with the new Github projects 🙁
Unfortunately, it seems that the client does not support the new projects system natively, as detailed on this ticket:
The suggestion is instead to use the client to make a GraphQL mutation…
(At this point, I’m really starting to miss Jira with simple bulk issue updates)