Skip to content

Commit

Permalink
add head-sha (#5)
Browse files Browse the repository at this point in the history
* add head-sha
* add build step to ci
  • Loading branch information
juliangruber authored Nov 18, 2019
1 parent e4964af commit 4b1f443
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1
- name: npm install and build
run: |
npm ci
npm run build
- name: Find Pull Request
uses: ./
id: find-pull-request
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
branch: test
- run: echo "Your Pull Request has number ${number}"
- run: echo "Pull Request ${number} (${sha})"
env:
number: ${{ steps.find-pull-request.outputs.number }}
sha: ${{ steps.find-pull-request.outputs.head-sha }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ steps:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
branch: my-branch-name
- run: echo "Your Pull Request has number ${number}"
if: success() && steps.find-pull-request.outputs.number
- run: echo "Pull Request ${number} (${sha})"
env:
number: ${{ steps.find-pull-request.outputs.number }}
sha: ${{ steps.find-pull-request.outputs.head-sha }}
```
Currently this will find a single open PR based on given `branch` input. For more options please open an issue.
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ inputs:
outputs:
number:
description: The Pull Request's number if one was found (e.g. '345' for #345)
head-sha:
description: The Pull Request's head sha if one was found
runs:
using: 'node12'
main: 'dist/index.js'
2 changes: 2 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,9 @@ const main = async () => {

const pr = res.data.length && res.data[0]

core.debug(`pr: ${JSON.stringify(pr, null, 2)}`)
core.setOutput('number', pr ? pr.number : '')
core.setOutput('head-sha', pr ? pr.head.sha : '')
}

main().catch(err => core.setFailed(err.message))
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const main = async () => {

const pr = res.data.length && res.data[0]

core.debug(`pr: ${JSON.stringify(pr, null, 2)}`)
core.setOutput('number', pr ? pr.number : '')
core.setOutput('head-sha', pr ? pr.head.sha : '')
}

main().catch(err => core.setFailed(err.message))

0 comments on commit 4b1f443

Please sign in to comment.