Skip to content

Commit

Permalink
Merge pull request #25 from TreTuna/add-pr-url-output
Browse files Browse the repository at this point in the history
Add pr url output
  • Loading branch information
TreTuna authored Mar 12, 2020
2 parents 6c7dda0 + 1308850 commit f85e82f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
node-version: 12
- name: Opening pull request
id: pull
uses: tretuna/sync-branches@v1
uses: ./
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
ACTIONS_RUNNER_DEBUG: true
Expand Down
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
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +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."
icon: git-pull-request
color: green
branding:
icon: git-pull-request
color: green
inputs:
GITHUB_TOKEN:
description: "User token to be associated with this pull request."
Expand All @@ -18,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 f85e82f

Please sign in to comment.