Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commit input to make it possible to use this action with third party PRs #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ In order to use this action, you will need to generate a JSON file using the fol

**Optional** Ignore if the file which contains annotations is missing. Default: "true".

### `commit`

**Optional** Commit SHA to which annotations are published.

## Example usage

```yml
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ inputs:
description: 'Ignore if the file which contains annotations is missing'
required: false
default: 'true'
commit:
description: 'Commit SHA to which annotations are published.'
required: false
runs:
using: 'node16'
main: 'dist/index.js'
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ async function run () {
const title = getInput('title', { required: false })

const octokit = getOctokit(repoToken)
const commitId = getInput('commit', { required: false }}
const pullRequest = context.payload.pull_request
let ref
if (pullRequest) {
if (commitId) {
ref = commitId
} else if (pullRequest) {
ref = pullRequest.head.sha
} else {
ref = context.sha
Expand Down