From 499910c3f7bf65dc470ed10523f6c88b82198044 Mon Sep 17 00:00:00 2001 From: Daniel Walsh Date: Mon, 25 Jan 2021 16:17:16 +0000 Subject: [PATCH] Add a new output `applied` which shows the label added (#1) --- action.yml | 3 +++ index.js | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/action.yml b/action.yml index bc4a428..e4ed45f 100644 --- a/action.yml +++ b/action.yml @@ -4,6 +4,9 @@ inputs: token: description: 'GitHub Token for the user to perform label additions. Use `secrets.GITHUB_TOKEN` for the actions bot' required: true +outputs: + applied: + description: The label applied to the Pull Request. If no label was applied this will be null. runs: using: 'node12' main: 'index.js' diff --git a/index.js b/index.js index d4cc72f..5a04e04 100644 --- a/index.js +++ b/index.js @@ -25,6 +25,7 @@ async function run() { const branch = data.data.head.ref; + let labelApplied = null; for (let prefix of labels) { let tmp = prefix; if (!prefix.endsWith('/')) @@ -35,8 +36,12 @@ async function run() { const label = process.env['INPUT_' + tmp.toUpperCase()]; console.log(`Adding ${label} to #${prNumber}`); await addLabels(client, prNumber, [label]); + labelApplied = label; + break; } } + + core.setOutput('applied', labelApplied); } catch (error) { console.error(error); core.setFailed(error.message);