Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
Signed-off-by: Luiz Ferraz <[email protected]>
  • Loading branch information
Fryuni committed Nov 9, 2023
1 parent 4ec89f6 commit 4ecc138
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,53 @@ You can disable checking the body by setting the flag `skip-body-check`:
skip-body-check: 'true'
```

## Validating PR commit messages

When triggered by a `pull_request` event, the action checks the title and the
body of the pull request by default. GitHub does not include the content of the
commit message in the workflow context, so checking all the commit messages of
the PR requires additional API calls. If you want to check the commit messages
for pull requests you can either:

- Trigger the action on `push` events. This will check the commit messages of
each pushed commit, but it will run even for branches that do not have a PR
associated with them.
- Set the `validate-pull-request-commits` option to `true`. This will check the
messages of every commit in the PR. However, because it requires extra API calls
to retrieve the commit messages, setting this on option on _private_ repositories
require a GitHub token with at least `read` permission on the `contents` scope.
See the [GitHub documentation](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token).

```yaml
steps:
- name: Check
uses: mristin/[email protected]
with:
validate-pull-request-commits: 'true'
# Required for private repos
github-token: ${{ secrets.GITHUB_TOKEN }}
```

> [!NOTE]
> The default permissions for a GitHub Actions workflow is sufficient for this action to work.
> You only need to check permissions if you are already customizing the permissions of the workflow
>
> ```yaml
> jobs:
> check-commits:
> # If you have this line,
> permissions:
> # Make sure this you also have this line
> contents: read
> steps:
> - name: Check
> uses: mristin/[email protected]
> with:
> validate-pull-request-commits: 'true'
> # Required for private repos
> github-token: ${{ secrets.GITHUB_TOKEN }}
> ```

## Enforce Sign-off

Most projects do not require a sign-off on the commits.
Expand Down

0 comments on commit 4ecc138

Please sign in to comment.