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

Default pull request events to the branch HEAD commit #21

Merged
merged 5 commits into from
Jun 19, 2020
Merged
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
10 changes: 1 addition & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ jobs:
with:
name: action.yml
path: action.yml
- id: vars
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great if this can be avoided in all workflows where you’d want to support both branch pushes and PRs.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. It was a bit of an oversight that I didn't add this into the action earlier. Thanks for raising the issue!

echo "::set-output name=sha::${{ github.event.pull_request.head.sha }}"; \
else \
echo "::set-output name=sha::${{ github.sha }}"; \
fi

test:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
Expand All @@ -62,10 +55,9 @@ jobs:
- name: Test create commit comment
uses: ./
with:
sha: ${{ needs.build.outputs.sha }}
body: |
This is a multi-line test comment
- With GitHub **Markdown**
- With GitHub **Markdown** :sparkles:
- Created by [commit-comment][1]

[1]: https://github.com/peter-evans/commit-comment
Expand Down
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,47 @@ A GitHub action to create a comment for a commit on GitHub.
with:
body: |
This is a multi-line test comment
- With GitHub **Markdown**
- With GitHub **Markdown** :sparkles:
- Created by [commit-comment][1]

[1]: https://github.com/peter-evans/commit-comment
```

## Parameters
## Action inputs

- `token` - The GitHub authentication token. Defaults to `GITHUB_TOKEN`.
- `sha` - The commit SHA. Defaults to the current commit.
- `body` (**required**) - The contents of the comment.
- `path` - Relative path of the file to comment on.
- `position` - Line index in the diff to comment on.
| Name | Description | Default |
| --- | --- | --- |
| `token` | `GITHUB_TOKEN` or a `repo` scoped [PAT](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line). | `GITHUB_TOKEN` |
| `repository` | The full name of the target repository. | `github.repository` (current repository) |
| `sha` | The commit SHA. | `github.sha` OR, for `pull_request` events `github.event.pull_request.head.sha` |
| `body` | (**required**) The contents of the comment. | |
| `path` | Relative path of the file to comment on. | |
| `position` | Line index in the diff to comment on. | |

## Example

Here is an example setting all of the input parameters.
Here is an example setting optional input parameters.

```yml
- name: Create commit comment
uses: peter-evans/commit-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
sha: 843dea1cc2e721163c20a5c876b5b155f7f3aa75
body: |
This is a multi-line test comment
- With GitHub **Markdown**
- With GitHub **Markdown** :sparkles:
- Created by [commit-comment][1]

[1]: https://github.com/peter-evans/commit-comment
path: path/to/file.txt
position: 1
```

### Accessing commits in other repositories

You can create a commit comment in another repository by using a [PAT](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) instead of `GITHUB_TOKEN`.
The user associated with the PAT must have write access to the repository.

## License

[MIT](LICENSE)
6 changes: 4 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ inputs:
token:
description: 'The GitHub authentication token'
default: ${{ github.token }}
required: true
repository:
description: 'The full name of the target repository.'
default: ${{ github.repository }}
sha:
description: 'The commit SHA. Defaults to the current commit.'
description: 'The commit SHA.'
body:
description: 'The contents of the comment.'
required: true
Expand Down
Loading