Skip to content

Commit

Permalink
initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Walton committed Sep 10, 2019
0 parents commit 5a6cf7b
Show file tree
Hide file tree
Showing 373 changed files with 77,119 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
trailingComma: 'es5',
printWidth: 100,
tabWidth: 4,
semi: true,
singleQuote: true,
overrides: [
{
files: '*.md',
options: {
tabWidth: 2,
},
},
],
};
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# gh-find-current-pr

This action tries to figure out the current PR.

If the event is a `pull_request`, it's very easy to get the current PR number
from the context via `${{ github.event.number }}`, but unfortunately this
information does not seem to be readily available for a `push` event. This
action sends a request to GitHub to find the PR associated with the current SHA,
and returns it in the `pr` output.

## Usage

```yaml
steps:
- uses: actions/checkout@v1
# 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.pr
env:
PR: ${{ steps.findPr.outputs.pr }}
```
18 changes: 18 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: gh-find-current-pr
author: jwalton
description: Find a PR associated with the current commit.
inputs:
github-token:
description: The GitHub token used to create an authenticated client.
sha:
description: Sha to get PR for. Defaults to current sha.
required: false
outputs:
pr:
description: The PR if one was found. (e.g. '345' for #345)
runs:
using: node12
main: 'main.js'
branding:
icon: git-pull-request
color: blue
20 changes: 20 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const core = require('@actions/core');
const { GitHub, context } = require('@actions/github');

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

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

const pr = result.data.length > 0 && result.data[0].number;

core.setOutput('pr', pr || '');
}

main().catch(err => core.setFailed(err.message));
1 change: 1 addition & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/@actions/core/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 97 additions & 0 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@actions/core/lib/command.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions node_modules/@actions/core/lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/@actions/core/lib/command.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 94 additions & 0 deletions node_modules/@actions/core/lib/core.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5a6cf7b

Please sign in to comment.