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 thePEER 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, andfalse
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 individualbuild
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
- example:
paths_no_filter
defines paths that should be included in the matrix regardless of if they've been modifiedbatches
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
- Sets a commit status
- Updates a Github deployment status
- 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, andsuccess
otherwise.
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.
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 }}
This project is available under the Apache 2.0 License.
Copyright 2021 Expedia, Inc.