Skip to content

simple web service that listens to github org events and protects the main branch

Notifications You must be signed in to change notification settings

So-Sahari/branch-protection-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Branch Protection Service

Branch Protection Service is a web service that listens for organization events to protect the main/master branch from force pushing and branch deletion.

Requirements

  • A Github Personal Access Token
  • A Github Organization
  • Go (version 1.16+) if using binary
  • Docker if using container

Creating a Personal Access Token

Steps for creating a personal access token can be found here.

For scopes to the token, you can check the following boxes:

  • public_repo
  • admin:org
  • admin:repo_hook
  • admin:org_hook
  • write:discussion

Creating an Organization

Steps for creating an organization can be found here

Running the Web Service

Clone and build the repository.

go build 

The binary takes two inputs, token and org. token is the github personal access token string. org is the github organization name string.

Running the binary looks like this,

./branch-protection-service -token <github pat> -org <org name>

Alternatively, you can run this as a container. First build,

docker build -t branch-protection-service .

Run the container

docker run --rm -d --name bps -e TOKEN=<github pat> -e ORG=<org name> branch-protection-service

Design

The web service uses the personal access token of an authenticated user of a Github Organization to listen to Organization events. It polls events from the Organization every minute and checks to see if repositories have their main/master branch protected. If a new repository is created, and main/master branch established, it will protect that branch from force pushing and branch deletion. It will then open an issue and @mention the author, assigning the issue to them as notification.

Go Library

The go-github library is used to access the GitHub API.

Github Go SDK (unofficial) go-github godocs

About

simple web service that listens to github org events and protects the main branch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published