From 704bcd35ba19b8b2a821f0c4ce3b658d474e0e5d Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Wed, 8 May 2024 13:55:10 -0400 Subject: [PATCH] Adding output - result of the check --- action.yml | 3 +++ dist/index.js | 4 ++++ index.ts | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/action.yml b/action.yml index a2a8e88..3f22ab4 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,9 @@ inputs: github_configuration_token: description: the github access token to be used to access the config file using other github_configuration_* parameters. can differ from GITHUB_TOKEN. defaults to GITHUB_TOKEN required: false +outputs: + success: + description: true if the PR title is valid, false otherwise. Undefined if an error occurred. runs: using: node20 main: dist/index.js diff --git a/dist/index.js b/dist/index.js index dff2dfb..b3ab71f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10050,6 +10050,7 @@ const run = ({ configPath, localConfigPath, remoteConfigURL, GitHubConfigOwner, if (labels[i].name == CHECKS.ignoreLabels[j]) { core.info(`Ignoring Title Check for label - ${labels[i].name}`); removeLabel({ labels, name: LABEL.name }); + core.setOutput("success", true); return; } } @@ -10060,6 +10061,7 @@ const run = ({ configPath, localConfigPath, remoteConfigURL, GitHubConfigOwner, if (title.startsWith(CHECKS.prefixes[i])) { removeLabel({ labels, name: LABEL.name }); core.info(MESSAGES.success); + core.setOutput("success", true); return; } } @@ -10069,10 +10071,12 @@ const run = ({ configPath, localConfigPath, remoteConfigURL, GitHubConfigOwner, if (re.test(title)) { removeLabel({ labels, name: LABEL.name }); core.info(MESSAGES.success); + core.setOutput("success", true); return; } } yield titleCheckFailed({ config: { LABEL, CHECKS, MESSAGES } }); + core.setOutput("success", false); } catch (error) { core.info(error); diff --git a/index.ts b/index.ts index 420abae..f960920 100644 --- a/index.ts +++ b/index.ts @@ -283,6 +283,7 @@ const run = async ({ if (labels[i].name == CHECKS.ignoreLabels[j]) { core.info(`Ignoring Title Check for label - ${labels[i].name}`); removeLabel({ labels, name: LABEL.name }); + core.setOutput("success", true); return; } } @@ -295,6 +296,7 @@ const run = async ({ if (title.startsWith(CHECKS.prefixes[i])) { removeLabel({ labels, name: LABEL.name }); core.info(MESSAGES.success); + core.setOutput("success", true); return; } } @@ -305,11 +307,13 @@ const run = async ({ if (re.test(title)) { removeLabel({ labels, name: LABEL.name }); core.info(MESSAGES.success); + core.setOutput("success", true); return; } } await titleCheckFailed({ config: { LABEL, CHECKS, MESSAGES } }); + core.setOutput("success", false); } catch (error) { core.info(error); }