From 8d3bb50679205f249dd72d48580dfa98b0ca06e1 Mon Sep 17 00:00:00 2001 From: Casey Evanoff Date: Tue, 2 Feb 2021 12:15:50 -0700 Subject: [PATCH] use defaults to retrieve the github token and sha --- README.md | 2 -- action.yml | 5 +++-- main.js | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 615b1df..a5414cf 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 039efb4..2770422 100644 --- a/action.yml +++ b/action.yml @@ -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] diff --git a/main.js b/main.js index 461922a..3d67c49 100644 --- a/main.js +++ b/main.js @@ -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[0];