Last active
September 29, 2023 17:41
-
-
Save kuroppe1819/575c3f5d818daa2fc5c6d4d5323baecc to your computer and use it in GitHub Desktop.
Close all "Done" or "Canceled" status issues
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 | |
# Project(beta) を API で読み取るには read:project の権限が必要 | |
# 手元で実行する場合は gh auth login --scopes "read:project" で認証してから実行する | |
issues=$(gh api graphql --paginate -f query=' | |
query ($endCursor: String) { | |
organization(login: $organization_name){ | |
projectV2(number: $project_number) { | |
title | |
items(first: 100, after: $endCursor) { | |
totalCount | |
pageInfo { | |
hasNextPage | |
endCursor | |
} | |
nodes { | |
type | |
... on ProjectV2Item { | |
fieldValueByName(name: "Status") { | |
... on ProjectV2ItemFieldSingleSelectValue { | |
name | |
} | |
} | |
} | |
content { | |
... on Issue { | |
id | |
closed | |
} | |
} | |
} | |
} | |
} | |
} | |
}' | jq '.[].organization.projectV2.items.nodes[] | select(.fieldValueByName.name == "Done" or .fieldValueByName.name == "Canceled") | select(.type == "ISSUE") | select(.content.closed == false) | .content.id' | jq -r -s .[]) | |
for issue in $issues; do | |
gh api graphql -f query=' | |
mutation { | |
closeIssue(input: {issueId: "'$issue'"}) { | |
issue { | |
id | |
} | |
} | |
}' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment