Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pull request number, Add String cast to fix bug: https://github.com/actions/toolkit/issues/321 #28

Merged
merged 2 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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