docs(readme): Add information about pre-commit hook

releases/v3
Viktor Kuroljov 2020-07-13 04:29:25 +03:00
parent 0aa82ce2ad
commit 1fe4a38414
1 changed files with 43 additions and 0 deletions

View File

@ -18,6 +18,36 @@ This action will bump version, tag commit and generate a changelog with conventi
- **Optional** `skip-on-empty`: Boolean to specify if you want to skip empty release (no-changelog generated). This case occured when you push `chore` commit with `angular` for example. Default `'false'`. - **Optional** `skip-on-empty`: Boolean to specify if you want to skip empty release (no-changelog generated). This case occured when you push `chore` commit with `angular` for example. Default `'false'`.
- **Optional** `skip-version-file`: Do not update the version file. Default `'false'`. - **Optional** `skip-version-file`: Do not update the version file. Default `'false'`.
- **Optional** `skip-commit`: Do create a release commit. Default `'false'`. - **Optional** `skip-commit`: Do create a release commit. Default `'false'`.
- **Optional** `pre-commit`: Path to the pre-commit script file. No hook by default.
### Pre-Commit hook
> Function in a specified file will be run right before the git-add-git-commit phase, when the next
> version is already known and a new changelog has been generated. You can run any chores across your
> repository that should be added and commited with the release commit.
An absolute path to the `.js` script file must be provided when specifying the `pre-commit` hook. File
should contain all its dependencies bundled in itself just like for the webapp.
Script should:
- be a CommonJS module
- have a single export: `exports.preCommit = (props) => { /* ... */ }`
- not have any return value
- be bundled
`preCommit` function can be `async`.
Following props will be passed to the function as a single parameter:
```typescript
interface Props {
workspace: string; // same as process.env.GITHUB_WORKSPACE
tag: string; // Next tag e.g. v1.12.3
version: string; // Next version e.g. 1.12.3
}
export function preCommit(props: Props): void {}
```
## Outputs ## Outputs
@ -89,6 +119,16 @@ Use a custom file for versioning
version-file: 'my-custom-file.yaml' version-file: 'my-custom-file.yaml'
``` ```
Use a pre-commit hook
```yaml
- name: Conventional Changelog Action
uses: TriPSs/conventional-changelog-action@v3
with:
github-token: ${{ secrets.github_token }}
pre-commit: ${{ github.workspace }}/some/path/pre-commit.js # requires absolute path
```
Github releases Github releases
```yaml ```yaml
@ -129,6 +169,9 @@ $ act -j test-yaml -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -s gith
# To run / toml git versioning # To run / toml git versioning
$ act -j test-toml -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -s github_token=fake-token $ act -j test-toml -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -s github_token=fake-token
# To run pre-commit test
$ act -j test-pre-commit -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -s github_token=fake-token
``` ```
## [License](./LICENSE) ## [License](./LICENSE)