Skip to content

Instantly share code, notes, and snippets.

@joneff
Created February 1, 2022 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joneff/93f0a24d4c5fd98a7b8d1875c84d6af8 to your computer and use it in GitHub Desktop.
Save joneff/93f0a24d4c5fd98a7b8d1875c84d6af8 to your computer and use it in GitHub Desktop.
A collection of scripts for working with gh cli, issues and projects beta
# remove all theme related labels from issues with multiple theme labels
gh pr list --state closed --limit 1000 --json number --jq ".[] | .number" | xargs -I {} gh pr edit {} --remove-label T:Default,T:Bootstrap,T:Material,T:Classic
# get project ID by ORG and NUMBER
gh api graphql -f query='
query{
organization(login: "ORG"){
projectNext(number: NUMBER) {
id
}
}
}'
# add all closed issues to a project with a given ID
gh issue list --state closed --limit 4000 --json id --jq ".[] | .id" | xargs -I {} gh api graphql -f query='
mutation {
addProjectNextItem(
input: {
projectId: "PROJECT_ID"
contentId: "{}"
}
) {
projectNextItem {
id
}
}
}'
# delete items from project
gh api graphql -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectNext(number: $number) {
id
items(first:100) {
nodes {
id
title
}
}
}
}
}' -f org=ORG -F number=NUMBER | \
jq '.data.organization.projectNext.items.nodes | .[].id' | \
xargs -I {} gh api graphql -f query='
mutation {
deleteProjectNextItem(
input: {
projectId: "ID"
itemId: "{}"
}
) {
deletedItemId
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment