Giter VIP home page Giter VIP logo

auto-branch-protect's Introduction

Automatic Branch Protection

This is a service that listens to GitHub organization events. When a new repository is created the service will automatically enable branch protection on the default branch. It will then notify the repository creator of the enabled branch protections with a @mention by creating an issue within the repository.

Prerequisites

Create GitHub Webhook

Create a GitHub webhook in your organization by following the documentation. Note that this needs to be created at the organization level.

  1. For Payload URL
    1. Allow external ingress traffic on port 9000 to the host where this service will be running. It should look similar to: http://webhooks.example.com:9000/hooks/branch-protection
  2. Set Content type to application/json
  3. Set the webhook secret to any value (make note of this value, it will be used later)
  4. On the radio dial under Which events would you like to trigger this webhook?
    1. Select Let me select individual events
    2. Select Repositories

Create GitHub Personal Access Token (PAT)

  • Follow the documentation to create a PAT for use with this webhook service. Make note of the token value as it will be used later.

Install Container Runtime

This service uses a lightweight webhook server called webhook. It's possible to install webhook as a native Linux service, please refer to that repository on details for installing that way. However, in this example we will be containerizing this webhook service.

  • Install Docker on the host that will be running the branch protection web service.

Other container runtimes should work with this service as well.

Usage

On the host where the port 9000 firewall rule is applied run the command below, making sure to substitute the values used in the Create GitHub Webhook section.

docker run -d \
    -e WEBHOOK_SECRET=<webhook_secret> \
    -e GH_TOKEN=<github_pat> \
    -p 9000:9000 \
    ahromis/auto-branch-protect:latest

Once the service is running then create a new repo under your organization.

Production Considerations

This example runs on the HTTP protocol. For production use this should be run using HTTPS. Enabling HTTPS for this web service can be accomplished by enabling HTTPS for the webhook project by following the documentation or by using a TLS enabled load balancer in front of this service.

If enabling HTTPS by using the webhook project this repository will need to be forked, modified accordingly, and the container image will need to be rebuilt.

References

auto-branch-protect's People

Contributors

ahromis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.