Skip to content

Commit

Permalink
Support base/head branch (#9)
Browse files Browse the repository at this point in the history
* Support base branch

* Add "base" option to action.yml
  • Loading branch information
civitaspo authored Aug 19, 2020
1 parent 4b447dc commit 1fe120f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ inputs:
branch:
description: 'Branch name'
required: true
base:
description: 'The base branch name of the Pull Request'
required: false
outputs:
number:
description: The Pull Request's number if one was found (e.g. '345' for #345)
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ const { GitHub, context } = require('@actions/github')
const main = async () => {
const token = core.getInput('github-token')
const branch = core.getInput('branch')
const base = core.getInput('base', { required: false })

const octokit = new GitHub(token)

const res = await octokit.pulls.list({
...context.repo,
state: 'open',
head: `${context.repo.owner}:${branch}`
head: `${context.repo.owner}:${branch}`,
base
})

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

0 comments on commit 1fe120f

Please sign in to comment.