Coder Social home page Coder Social logo

koconder / no-out-of-hours-merge Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 168 KB

Github action to block out of business hours merges

License: GNU General Public License v3.0

Dockerfile 5.25% Makefile 19.88% Shell 2.66% Python 72.22%
actions devops-tools review

no-out-of-hours-merge's Introduction

⏰ No Out of Hours Merge (Github Action)

A GitHub Action that prevents merging pull requests outside of specified business hours or on weekends. This action can be configured with custom time zones, restricted times, and custom messages.

Features

  • Customizable time zone and restricted hours
  • Optional custom message for pull request comments
  • Allows hotfixes to bypass the time restrictions
  • Provides informative error messages and input validation
  • Allows for rules on specific days
  • Support for holidays (thanks to holidays pip package)

Requirements

Usage

To use the No Out of Hours Merge GitHub Action, add the following workflow to your GitHub repository:

name: No Out of Hours Merge

on:
  pull_request:
    types:
      - opened
      - synchronize
      - reopened

jobs:
  no_weekend_merge:
    name: Out of Hours Check ⏰
    runs-on: ubuntu-latest
    timeout-minutes: 2
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.9

      - name: Block merge during specified times
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          TIMEZONE: "Australia/Sydney"
          RESTRICTED_TIMES: >
            {
              "weekly": [
                {
                  "days": ["mon", "tue", "wed", "thu", "fri"],
                  "intervals": [[0, 7], [16.5, 24]]
                }
              ],
              "dates": [
                {
                  "date": "2023-12-25",
                  "intervals": [[0, 24]]
                }
              ],
              "holidays": {
                "country": "GB",
                "state": "UK",
                "intervals": [[0, 24]]
              }
            }
          CUSTOM_MESSAGE: "⚠️ **PR merging is not allowed outside business hours. Let's not be a cowboy!** ⚠️"
        run: no-weekend-merge

Configuration

You can configure the action using the following environment variables:

  • GITHUB_TOKEN: Required to post a message back to the PR.
  • CUSTOM_MESSAGE: The custom message that will be posted as a comment on the pull request if merging is not allowed (default: "⚠️ PR merging is not allowed outside business hours. ⚠️").
  • CHECK_EXISTING_COMMENT: Dont post the same message twice (default: enabled)
  • TIMEZONE: The timezone used for checking the current time (default: "Australia/Sydney").
  • RESTRICTED_TIMES: A JSON string containing the restricted times for each day of the week (default: the provided example in the Usage section).

License

This project is licensed under the GNU General Public License v3.0.

no-out-of-hours-merge's People

Contributors

koconder avatar dependabot[bot] avatar

Stargazers

Eugene Klimov avatar Tim Kersey avatar  avatar

Watchers

 avatar  avatar

Forkers

difki

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.