npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@auto-it/protected-branch

v11.1.6

Published

Handle Github branch protections

Downloads

5,234

Readme

protected-branch Plugin

Handle GitHub branch protections and avoid running auto with an admin token.

Prerequisites

This plugin still needs a Personal Access Token (PAT), but only for a standard user with write permission on your repository. No need to have an admin user.

That also means that you are able to enforce all branch protection requirements for Administrators of your Organization.

When enforcing CodeOwners, 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-branch

Usage

Add the protected-branch plugin to the list in .autorc.

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's intent is to handle branch protections, without the need to use an administrator's privileges and/or if you don't want to use an administrator token in our workflow.

An example usage in a repository where we want to have the following protected branch configuration:

branch-protection-part-1 branch-protection-part-2

  1. Create a bot account in this org ([email protected]).

  2. Create a PAT with this bot user and give it repo permissions.

  3. On the repository, create a GitHub actions secret with the previously created PAT.

  4. On the repository, grant write access to the bot account.

  5. When 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 [email protected]
    CHANGELOG.md    @prg/owner-team [email protected]
  6. In your build process .yml, be sure to add the PROTECTED_BRANCH_REVIEWER_TOKEN environment variable, and set it to the secret you created previously:

    permissions:
     # 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 shipit
  7. Ship it!

Limitations

This plugin is not yet ready to:

  • Handle more than 1 review requirement
  • Dynamically list required status checks on target protected branch