Skip to content

Commit

Permalink
feat: Handle unlabeled events
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jun 27, 2024
1 parent 52298c6 commit 52ddfa8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
26 changes: 17 additions & 9 deletions dist/index.js

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

26 changes: 17 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,23 @@ try {
// Temp environments enabled
if (github.context.eventName === "pull_request") {
const prEvent = github.context.payload;
const targetLabel = value.label;
if (!targetLabel) continue;
const hasLabel =
(prEvent.action === "labeled" &&
prEvent.label.name === targetLabel) ||
prEvent.pull_request.labels.some(
(label) => label.name === targetLabel,
);
if (hasLabel) {
let matches = false;
if (value.label) {
matches =
(prEvent.action === "labeled" &&
prEvent.label.name === value.label) ||
prEvent.pull_request.labels.some(
(label) => label.name === value.label,
);
} else if (value.removed_label) {
matches =
(prEvent.action === "unlabeled" &&
prEvent.label.name === value.removed_label) ||
!prEvent.pull_request.labels.some(
(label) => label.name === value.label,
);
}
if (matches) {
patterns = ref;
value.name = `${value.name || toTitleCase(env)} #${prEvent.number}`;
env += prEvent.number;
Expand Down

0 comments on commit 52ddfa8

Please sign in to comment.