Giter VIP home page Giter VIP logo

github-helpers's Introduction

Release

github-helpers

A collection of Github Actions that simplify and standardize common CI/CD workflow tasks.

Helpers:

Each of the following helpers are defined in a file of the same name in src/helpers:

  • Adds one or more labels to a PR
  • Upon PR review, adds a CORE APPROVED label if the reviewer is a part of the provided Github team, otherwise adds the PEER APPROVED label
  • Randomly assigns members of a github team to review a PR. If login is provided, it does nothing if that user is already part of the team
  • You can also pass a slack_webhook_url to notify the assignees that they are assigned to the PR!
  • Automatically approves a PR if the reviewer's login matches the provided login
  • Checks whether PR title matches a certain regular expression
  • Comments on a pull request or other issue
  • Returns true if specified file paths have changed for a PR, and false otherwise
  • Returns a job matrix JSON for dynamically running workflows only for changed file paths
  • Can be used to parallelize similar jobs, which can be useful in a monorepo environment. More information on matrix strategies can be found here
  • In this example, a multi-package repo splits its builds dynamically based on which packages are modified in the pull request. These builds run in parallel, and the final build-status job is used to determine the overall success/failure result, contingent on all of the individual build jobs passing. The helper returns a JSON object of this format:
{
  "include": [
    { "path": "package-name" }
  ]
}

Additionally, the following parameters can be used for additional control over the resulting matrix:

  • override_filter_paths defines paths that, if modified, will override the filter and return a matrix including all packages
    • example: override_filter_paths: package.json,package-lock.json
  • paths_no_filter defines paths that should be included in the matrix regardless of if they've been modified
  • batches defines a fixed number of matrix jobs to run for the workflow
  • Returns a comma-separated list of changed files for a PR
  • Creates a new in-progress Github "deployment" for a commit. More information on Github deployment events can be found here
  • Sets a "pipeline" commit status to green for all open PRs
  • Merges the default branch into the pull request that has the QUEUED FOR MERGE #1 label
  • Removes a label from a PR
  • Determines whether the pipeline is clear for a PR. This means it will set the "pipeline" commit status to pending if there is an in-progress production deployment for the repo, and success otherwise.

Usage

General

uses: actions/github-helpers@v1
with:
  helper: < HELPER NAME >
  ...
  github_token: ${{ secrets.GITHUB_TOKEN }}

The helper and github_token inputs are required for all helpers. Additional inputs vary by helper. Each helper file in src/helpers contains an interface that defines which additional inputs are required or optional.

Example

Input interface in src/helpers/set-commit-status.ts:

interface SetCommitStatus {
  sha: string;
  context: string;
  state: PipelineState;
  description?: string;
  target_url?: string;
}

Github Actions workflow invocation:

uses: actions/github-helpers@v1
with:
  helper: set-commit-status
  sha: ${{ github.event.pull_request.head.sha }}
  context: My Context
  state: success
  description: My Description
  github_token: ${{ secrets.GITHUB_TOKEN }}

Legal

This project is available under the Apache 2.0 License.

Copyright 2021 Expedia, Inc.

github-helpers's People

Contributors

dependabot[bot] avatar mcaulifn avatar danadajian 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.