Skip to content

Commit

Permalink
Merge pull request #9 from justAnotherDev/infer-token
Browse files Browse the repository at this point in the history
use defaults to retrieve the github token and sha
  • Loading branch information
jwalton authored Feb 11, 2021
2 parents da4a054 + 8d3bb50 commit 932bdfd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Additionally, `title` and `body` outputs are available as well to get the respec
# Find the PR associated with this push, if there is one.
- uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# This will echo "Your PR is 7", or be skipped if there is no current PR.
- run: echo "Your PR is ${PR}"
if: success() && steps.findPr.outputs.number
Expand Down
5 changes: 3 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ author: jwalton
description: Find a PR associated with the current commit.
inputs:
github-token:
description: The GitHub token used to create an authenticated client.
description: The GitHub token used to create an authenticated client. Defaults to github provided token.
default: ${{ github.token }}
sha:
description: Sha to get PR for. Defaults to current sha.
required: false
default: ${{ github.sha }}
outputs:
pr:
description: The PR if one was found. (e.g. '345' for #345) [Deprecated: Please use number instead]
Expand Down
4 changes: 2 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ const { GitHub, context } = require('@actions/github');

async function main() {
const token = core.getInput('github-token', { required: true });
const sha = core.getInput('sha');
const sha = core.getInput('sha', { required: true});

const client = new GitHub(token, {});
const result = await client.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: sha || context.sha,
commit_sha: sha,
});

const pr = result.data.length > 0 && result.data.filter(el => el.state === 'open')[0];
Expand Down

0 comments on commit 932bdfd

Please sign in to comment.