Skip to content

Fix validation of shared source repositories #47

Fix validation of shared source repositories

Fix validation of shared source repositories #47

Workflow file for this run

name: PR label
on:
pull_request:
types: [opened, reopened, synchronize, labeled, unlabeled]
jobs:
labels:
runs-on: ubuntu-latest
steps:
- name: Require a lerna-changelog label
uses: actions/github-script@v9
with:
script: |
const required = ["breaking", "enhancement", "bug", "documentation", "internal"];
const pullRequest = context.payload.pull_request;
// Dependabot and friends label their own PRs (dependencies,
// javascript, github_actions) and cannot be asked to pick a
// changelog label, so the gate does not apply to them. Passing
// rather than skipping the job keeps the check reportable if it
// ever becomes a required status check.
if (pullRequest.user.type === "Bot") {
core.info(
`Skipping the changelog label check for bot author ${pullRequest.user.login}.`,
);
return;
}
const labels = pullRequest.labels.map((label) => label.name);
const matched = labels.filter((label) => required.includes(label));
if (matched.length === 0) {
core.setFailed(
`This PR needs one of the following labels for the changelog: ${required.join(", ")}.`,
);
}