Skip to content

Commit

Permalink
feat(pr-url-output): add PULL_REQUEST_URL output variable
Browse files Browse the repository at this point in the history
This is set to either the generated PR or the one that was found to be already open.
  • Loading branch information
Tre Ammatuna committed Mar 12, 2020
1 parent 5a2a931 commit 1308850
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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."
Expand All @@ -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"
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1308850

Please sign in to comment.