From 13088503ebc9ac0346adf2415b3e1706e5a67a55 Mon Sep 17 00:00:00 2001 From: Tre Ammatuna Date: Wed, 11 Mar 2020 22:34:56 -0700 Subject: [PATCH] feat(pr-url-output): add PULL_REQUEST_URL output variable This is set to either the generated PR or the one that was found to be already open. --- README.md | 6 ++++++ action.yml | 7 +++++-- index.js | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 18eeed50..7c6516e7 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,12 @@ What you would like in the body of the pull request. Default: `sync-branches: New code has just landed in {FROM_BRANCH} so let's bring {TO_BRANCH} up to speed!` +## Outputs + +### `PULL_REQUEST_URL` + +Set to the URL of either the pull request that was opened by this action or the one that was found to already be open between the two branches. + ## Example usage ```YML diff --git a/action.yml b/action.yml index 19fd9570..a88d181f 100644 --- a/action.yml +++ b/action.yml @@ -1,8 +1,8 @@ name: "Sync branches" description: "GitHub Action to, upon successful merge, open a pull request to sync the updated branch back to one or more other branches." branding: -icon: git-pull-request -color: green + icon: git-pull-request + color: green inputs: GITHUB_TOKEN: description: "User token to be associated with this pull request." @@ -19,6 +19,9 @@ inputs: PULL_REQUEST_BODY: description: "What you would like in the body of the pull request. Default: 'New code has just landed in {fromBranch} so let's bring {toBranch} up to speed!'" required: false +outputs: + PULL_REQUEST_URL: + description: "URL for either the generated pull request or the currently open one" runs: using: "node12" main: "dist/index.js" diff --git a/index.js b/index.js index 7f614667..e5c9562e 100644 --- a/index.js +++ b/index.js @@ -43,11 +43,15 @@ async function run() { console.log( `Pull request successful! You can view it here: ${pullRequest.url}.` ); + + core.setOutput("PULL_REQUEST_URL", pullRequest.url); } else { console.log( `There is already a pull request to ${toBranch} from ${fromBranch}.`, `You can view it here: ${currentPull.url}` ); + + core.setOutput("PULL_REQUEST_URL", currentPull.url); } } catch (error) { core.setFailed(error.message);