Skip to content

Commit

Permalink
Merge pull request #28 from urbanmedia/master
Browse files Browse the repository at this point in the history
Add pull request number, Add String cast to fix bug: actions/toolkit#321
  • Loading branch information
TreTuna committed Apr 7, 2020
2 parents be864cf + cd4675a commit 59c12d0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
13 changes: 10 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 59c12d0

Please sign in to comment.