Package Exports
- @auto-it/protected-branch
- @auto-it/protected-branch/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@auto-it/protected-branch) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Protected-Branch Plugin
Handle Github branch protections and avoid run auto with an admin token
Prerequisites
This plugin still needs Personal Access token (PAT), but only with for a standard user with write permission on your repository.
That's means no need to have an Administration user.
That's also means that you are able to enforce all branches protection requirements for Administrators of your Organization.
When enforcing code owners, This user/ or a team must be designated as Owner/Co-Owner of released files.
Installation
This plugin is not included with the auto CLI installed via NPM. To install:
npm i --save-dev @auto-it/protected-branch
# or
yarn add -D @auto-it/protected-branchUsage
No config example :
{
"plugins": [
"protected-branch"
// other plugins
]
}Fully configured example :
{
"plugins": [
[
"protected-branch",
{
"reviewerToken": "redacted", // Probably better idea to set it in `PROTECTED_BRANCH_REVIEWER_TOKEN` environment variable
"releaseTemporaryBranchPrefix": "protected-release-",
"requiredStatusChecks": ["check-1", "check-2"]
}
]
// other plugins
]
}Configuration
How to handle branch protection
The plugin intent to handled branches protections, without the need to use an administrators privileges or/and don't want to use administrator token in our workflow.
An example usage in a repository where we want to have the following protected branch configuration :

Create a bot account in this org (
auto-release-bot@org.com)Create a PAT with this bot user and give a
repopermissionsOn the repository, create a github actions secrets with the previously created PAT
On the repository, add
writeaccess to the bot accountWhen using CodeOwners, on the repository, for each released asset, let the bot account be owner and/or co-owners of each asset
# Automatically released files must be also owned by our automation @bots team package.json @org/owner-team auto-release-bot@org.com CHANGELOG.md @prg/owner-team auto-release-bot@org.comConfigure this plugin correctly (see Configuration)
On the repository, be sure add
PROTECTED_BRANCH_REVIEWER_TOKENenvironment variable, and included the relevant permissionspermissions: # Needed to create PR statuses/checks checks: write statuses: write # Needed to push git tags, release contents: write ... # On auto shipit job step - name: Release env: PROTECTED_BRANCH_REVIEWER_TOKEN: ${{ secrets.<<YOUR-GITHUB-ACTIONS-SECRET-NAME>> }} run: yarn shipitShip it !
Limitations
This plugin is not yet ready to :
- Handle more than 1 review requirement
- Dynamically list required status checks on target protected branch