Created
September 10, 2024 23:44
-
-
Save ChrisTitusTech/1a995477dd21e3623fdbe749806b3cac to your computer and use it in GitHub Desktop.
set labels on PRs using powershell and GH
This file contains hidden or 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
# Ensure the GitHub CLI is authenticated | |
gh auth status | |
# Initialize an empty array to hold all closed PRs | |
$allClosedPRs = @() | |
# Fetch closed PRs with a higher limit | |
$closedPRs = gh pr list --state closed --json number,labels --limit 500 | |
$closedPRs = $closedPRs | ConvertFrom-Json | |
$allClosedPRs += $closedPRs | |
# Add the skip-changelog label to each closed PR if it doesn't already have it | |
foreach ($pr in $allClosedPRs) { | |
$prNumber = $pr.number | |
$labels = $pr.labels | ForEach-Object { $_.name } | |
if ($labels -notcontains "skip-changelog") { | |
# Add the skip-changelog label | |
gh pr edit $prNumber --add-label "skip-changelog" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment