Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete Branch After Merge #138

Open
ben51degrees opened this issue Jan 3, 2025 · 5 comments
Open

Delete Branch After Merge #138

ben51degrees opened this issue Jan 3, 2025 · 5 comments
Assignees

Comments

@ben51degrees
Copy link
Contributor

After the Nightly PRs to Main workflow merges a PR, the source branch should be deleted by default.

This keeps the repo tidy by removing branches which are no longer needed.

For PRs from external forks, the branch should not be deleted, as it not a 51Degrees repo (and the delete would fail anyway)

@pi-alexander-popel
Copy link
Collaborator

@justadreamer
Copy link
Contributor

justadreamer commented Jan 17, 2025

@pi-alexander-popel can it be done automatically using some gh command option when we are merging? it is kinda tedious to switch on every repo...

@pi-alexander-popel
Copy link
Collaborator

@justadreamer
Copy link
Contributor

When we have time let's write a script that'd utilize gh command to update settings of each repo in the org to enable this option per repo.

@pi-alexander-popel
Copy link
Collaborator

Here's the PowerShell script:

$org = '51Degrees'
$list = gh repo list 51Degrees --no-archived --limit 256 --json name --jq '.[].name'

Write-Host -Separator "`n" $list
Write-Host '---------'
$confirm = Read-Host 'The repositories above will have the "Delete branch on merge" setting enabled. Continue [y/N]'
if ($confirm -like 'y*') {
    foreach ($repo in $list) {
        gh repo edit $org/$repo --delete-branch-on-merge
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants