Skip to content

Commit

Permalink
Merge pull request #3 from replicatedhq/pr-labels
Browse files Browse the repository at this point in the history
add mapping to get label names, add debug logging, update deps
  • Loading branch information
e3b0c442 authored Feb 9, 2023
2 parents 5b17bf5 + 34e949d commit 67f51f1
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 102 deletions.
179 changes: 93 additions & 86 deletions .github/actions/pr-labels/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/actions/pr-labels/dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/actions/pr-labels/dist/sourcemap-register.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions .github/actions/pr-labels/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .github/actions/pr-labels/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@actions/github": "^5.1.1"
},
"devDependencies": {
"@vercel/ncc": "^0.31.1",
"eslint": "^8.0.0"
"@vercel/ncc": "^0.36.1",
"eslint": "^8.33.0"
}
}
15 changes: 11 additions & 4 deletions .github/actions/pr-labels/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ async function run() {
...github.context.repo,
issue_number: github.context.issue.number,
})
).data;
).data.map((label) => label.name);
core.debug(`Found labels: ${labels.join(", ")}`);

// ensure exactly one primary label is set
const primaryLabels = PRIMARY_LABELS.filter((label) => labels.includes(label));
const primaryLabels = PRIMARY_LABELS.filter((label) =>
labels.includes(label)
);
core.debug(`Found primary labels: ${primaryLabels.join(", ")}`);
if (primaryLabels.length !== 1) {
throw new Error(
`Exactly one primary label must be set. Found: ${primaryLabels.join(
Expand All @@ -42,6 +46,7 @@ async function run() {
// if the primary label is a bug, ensure a bug label is set
if (primaryLabels[0] === "type::bug") {
const bugLabels = BUG_LABELS.filter((label) => labels.includes(label));
core.debug(`type::bug is set, found bug labels: ${bugLabels.join(", ")}`);
if (bugLabels.length !== 1) {
throw new Error(
`Exactly one bug label must be set for primary type::bug. Found: ${bugLabels.join(
Expand All @@ -52,15 +57,17 @@ async function run() {
}

// ensure no more than one severity label is set
const severityLabels = SEVERITY_LABELS.filter((label) => labels.includes(label));
const severityLabels = SEVERITY_LABELS.filter((label) =>
labels.includes(label)
);
core.debug(`Found severity labels: ${severityLabels.join(", ")}`);
if (severityLabels.length > 1) {
throw new Error(
`No more than one severity label may be set. Found: ${severityLabels.join(
", "
)}`
);
}

} catch (error) {
if (error instanceof Error) core.setFailed(error.message);
}
Expand Down

0 comments on commit 67f51f1

Please sign in to comment.