diff --git a/README.md b/README.md index f8d03a23..67832864 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,11 @@ Default: `sync-branches: New code has just landed in {FROM_BRANCH} so let's brin 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. + +### `PULL_REQUEST_NUMBER` + +Pull request number from generated pull request or the currently open one + ## Example usage ```YML diff --git a/action.yml b/action.yml index a88d181f..9bb02c52 100644 --- a/action.yml +++ b/action.yml @@ -22,6 +22,8 @@ inputs: outputs: PULL_REQUEST_URL: description: "URL for either the generated pull request or the currently open one" + PULL_REQUEST_NUMBER: + description: "Pull request number from generated pull request or the currently open one" runs: using: "node12" main: "dist/index.js" diff --git a/dist/index.js b/dist/index.js index 20eea441..e5b6d665 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2021,13 +2021,20 @@ async function run() { }); console.log( - `Pull request successful! You can view it here: ${pullRequest.url}.` + `Pull request (${pullRequest.number}) successful! You can view it here: ${pullRequest.url}.` ); + + core.setOutput("PULL_REQUEST_URL", pullRequest.url.toString()) + core.setOutput("PULL_REQUEST_NUMBER", pullRequest.number.toString()); + } else { console.log( - `There is already a pull request to ${toBranch} from ${fromBranch}.`, - `You can view it here: ${currentPull.url}` + `There is already a pull request (${currentPull.number}) to ${toBranch} from ${fromBranch}.`, + `You can view it here: ${currentPull.url}` ); + + core.setOutput("PULL_REQUEST_URL", currentPull.url.toString()); + core.setOutput("PULL_REQUEST_NUMBER", currentPull.number.toString()); } } catch (error) { core.setFailed(error.message); diff --git a/index.js b/index.js index e5c9562e..bb21a219 100644 --- a/index.js +++ b/index.js @@ -41,17 +41,19 @@ async function run() { }); console.log( - `Pull request successful! You can view it here: ${pullRequest.url}.` + `Pull request (${pullRequest.number}) successful! You can view it here: ${pullRequest.url}.` ); - core.setOutput("PULL_REQUEST_URL", pullRequest.url); + core.setOutput("PULL_REQUEST_URL", pullRequest.url.toString()); + core.setOutput("PULL_REQUEST_NUMBER", pullRequest.number.toString()); } else { console.log( - `There is already a pull request to ${toBranch} from ${fromBranch}.`, + `There is already a pull request (${currentPull.number}) to ${toBranch} from ${fromBranch}.`, `You can view it here: ${currentPull.url}` ); - core.setOutput("PULL_REQUEST_URL", currentPull.url); + core.setOutput("PULL_REQUEST_URL", currentPull.url.toString()); + core.setOutput("PULL_REQUEST_NUMBER", currentPull.number.toString()); } } catch (error) { core.setFailed(error.message);