From d1d0ce4cade6e892737759d5b33b2d7bbe8635e8 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Thu, 27 Jun 2024 13:49:19 -0500 Subject: [PATCH] feat: Handle `unlabeled` events --- dist/index.js | 23 ++++++++++++++--------- src/index.js | 23 ++++++++++++++--------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6610c8a..d9a2b2d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36944,15 +36944,20 @@ 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; + } + if (matches) { patterns = ref; value.name = `${value.name || toTitleCase(env)} #${prEvent.number}`; env += prEvent.number; diff --git a/src/index.js b/src/index.js index 60d5f0d..1ecaf6f 100644 --- a/src/index.js +++ b/src/index.js @@ -31,15 +31,20 @@ 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; + } + if (matches) { patterns = ref; value.name = `${value.name || toTitleCase(env)} #${prEvent.number}`; env += prEvent.number;