Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
user-check

GitHub Action

Github Helpers

v1.1.0

Github Helpers

user-check

Github Helpers

A suite of Github helper actions

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Github Helpers

uses: ExpediaGroup/[email protected]

Learn more about this action in ExpediaGroup/github-helpers

Choose a version

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!
  • Creates a Project card into your GitHub Project repository by providing a project_name and project_destination_column_name in which the card should be created.
  • If note is provided, it will add that information into the card. If it is not provided, it will use the PR information details to populate it.
  • Useful when opening a pull request and want to track its information details into a GitHub Project.
  • Moves a GitHub Project card to a new column, using the project_origin_column_name andproject_destination_column_name you provide.
  • In order to move a card from one place to another, it must already exist.
  • 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.