From 1da4052fab21d9692e4a9b8be8c082ce90fe6a4a Mon Sep 17 00:00:00 2001 From: Gregory Schofield Date: Thu, 2 Nov 2023 10:19:29 -0400 Subject: [PATCH] Output a JIRA key if found. Signed-off-by: Gregory Schofield --- README.md | 1 + action.yml | 2 ++ src/main.ts | 12 +++++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 54b3435..e4e3ce3 100755 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ When a PR passes the above check, `jira-description-action` will also add the is | key | description | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `jira-issue-key` | The JIRA issue key. If key is not found the value is an empty string |**** | `jira-issue-found` | Indication whether a jira issue was found or not | | `jira-issue-source` | Indication how the jira issue was found, by - `branch \| pr-title \| null` | diff --git a/action.yml b/action.yml index cba3514..8072a7b 100755 --- a/action.yml +++ b/action.yml @@ -31,6 +31,8 @@ inputs: required: false default: 'false' outputs: + jira-issue-key: + description: 'The JIRA issue key. If key is not found the value is an empty string' jira-issue-found: description: 'Indication whether a jira issue was found or not' jira-issue-source: diff --git a/src/main.ts b/src/main.ts index b4ad27f..899fa8c 100755 --- a/src/main.ts +++ b/src/main.ts @@ -16,12 +16,12 @@ async function run(): Promise { if (!githubConnector.isPRAction) { console.log('This action meant to be run only on PRs'); - setOutputs(false, null); + setOutputs(null, null); process.exit(0); } if (shouldSkipBranch(githubConnector.headBranch, BRANCH_IGNORE_PATTERN)) { - setOutputs(false, null); + setOutputs(null, null); process.exit(0); } @@ -30,11 +30,11 @@ async function run(): Promise { const details = await jiraConnector.getTicketDetails(key); await githubConnector.updatePrDetails(details); - setOutputs(true, source); + setOutputs(key, source); } catch (error) { console.log('Failed to add JIRA description to PR.'); core.error(error.message); - setOutputs(false, null); + setOutputs(null, null); if (FAIL_WHEN_JIRA_ISSUE_NOT_FOUND) { core.setFailed(error.message); process.exit(1); @@ -44,7 +44,9 @@ async function run(): Promise { } } -function setOutputs(isFound: boolean, source: ESource | null): void { +function setOutputs(key: string | null, source: ESource | null): void { + var isFound = key !== null; + core.setOutput('jira-issue-key', key); core.setOutput('jira-issue-found', isFound); core.setOutput('jira-issue-source', source || 'null'); }