Oakkeeper
CLI to set branch protection of a Github respository in a Zalando-compliant way.
It makes sure that for any repository:
- The default branch is protected
- Enforcement level is set to
everyone
(includes admins) - Zappr is a required status check
- Zappr checks of your choice are enabled
Installation
pip3 install --upgrade oakkeeper
Usage
If you just type oakkeeper
, it will prompt for the Github API Base URL (defaults to Github.com), the Zappr Base URL (defaults to Zappr Opensource) and the access token to use. Be aware that the token needs repo
scope at least, for Zappr check management also admin:repo_hook
. Afterwards it will read all repositories you have access to and asks to enable branch protection.
Alternatively you can provide the repository patterns as a space-separated list like so:
oakkeeper zalando-stups/yourturn zalando/.*
Options
- Access token:
--token
or environment variableOK_TOKEN
. Needsrepo
scope. - Github Url:
--base-url
or environment variableOK_BASE_URL
. For Github Enterprise this is<github enterprise url>/api/v3
. - Zappr Url:
--zappr-base-url
or environment variableOK_ZAPPR_BASE_URL
. For Zappr Enterprise use URL of your ZE installation. - "Yes to all":
--yes
or environment variableOK_YES
You can also directly upload a local .zappr.yaml
or an issue/PR template to every repository:
- Path to
.zappr.yaml
:--zappr-path
orOK_ZAPPR_PATH
- Path to
ISSUE_TEMPLATE.md
:--issue-template-path
orOK_ISSUE_TEMPLATE_PATH
- Path to
PULL_REQUEST_TEMPLATE.md
:--pr-template-path
orOK_PULL_REQUEST_TEMPLATE_PATH
- Upload type:
--upload-type
orOK_UPLOAD_TYPE
. Might becommit
(commit to default branch) orpr
(open pull request).
To enable/disable checks in Zappr use these:
-
--enable
: Enables a Zappr check (currentlyapproval
,commitmessage
orautobranch
) for a repository -
--disable
: Disables a Zappr check for a repository
License
Apache 2, see LICENSE.