-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
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, | ||
}, | ||
}, | ||
], | ||
}; |
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 }} | ||
``` |
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 |
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)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.