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

Add branch protection for release branches #71

Open
Slamdunk opened this issue Mar 18, 2021 · 1 comment
Open

Add branch protection for release branches #71

Slamdunk opened this issue Mar 18, 2021 · 1 comment

Comments

@Slamdunk
Copy link
Contributor

Slamdunk commented Mar 18, 2021

See laminas/automatic-releases#126

Here's a sample script to batch apply the allow_force_pushes:false rule to every laminas repository.

It must be done by someone with admin privileges over all repositories.

#!/bin/bash
set -ex

cd "$(mktemp -d)" || exit 1

GITHUB_TOKEN=xxx

curl \
    -H "Accept: application/vnd.github.v3+json" \
    -H "Authorization: token $GITHUB_TOKEN" \
    https://api.github.com/orgs/laminas/repos \
    > repos.json

for repo in $(jq -c '{name:.[].name,default_branch:.[].default_branch}' repos.json); do
    repo_name="$(echo "$repo" | jq .name)"
    repo_default_branch="$(echo "$repo" | jq .default_branch)"

    curl \
        -X PUT \
        -H "Accept: application/vnd.github.v3+json" \
        -H "Authorization: token $GITHUB_TOKEN" \
        "https://api.github.com/repos/laminas/$repo_name/branches/$repo_default_branch/protection" \
        -d '{"branch":"*.*.x","allow_force_pushes":false}'

    break # To test it on the first repo
done

We should also write a note somewhere for new repositories.

UPDATE

If this is going to be discussed in the TSC agenda, it's worth discussion all the available features, see https://docs.github.com/en/github/administering-a-repository/about-protected-branches#about-branch-protection-settings

@weierophinney
Copy link
Member

This is something we need to discuss in the TSC before applying. Could you create a PR against the next meeting agenda for us to discuss (https://github.com/laminas/technical-steering-committee — agenda is meetings/agenda.md)? And then, if you can, attend the next meeting (2021-04-05 at 19:00UTC) to discuss.

Thanks!

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

2 participants