Skip to content

Instantly share code, notes, and snippets.

@ChrisTitusTech
Created September 10, 2024 23:44
Show Gist options
  • Save ChrisTitusTech/1a995477dd21e3623fdbe749806b3cac to your computer and use it in GitHub Desktop.
Save ChrisTitusTech/1a995477dd21e3623fdbe749806b3cac to your computer and use it in GitHub Desktop.
set labels on PRs using powershell and GH
# 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