feat(action): need a custom action for `commitlint`
- Dominant language
- Shell
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## Goals
- checks if PR titles conform commitlint header
- checks if PR body conforms to commitlint body
- If it's run as a result of a pull request, it lints all the commits from the pull request (up to 250). If it's run as the result of a push, it lints all the commits in that branch. Otherwise, it lints all the commits on the default branch
- based on the action event_name.
- `push`: The last commit; from `HEAD~1` to `HEAD`
- `pull_request`: from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} to ${{ github.event.pull_request.head.sha }}
- configure your GitHub repository to use the squash & merge strategy and tick the option "Default to PR title for squash merge commits".
- [ ] filter by author
- [ ] exclude merged commits
- [ ] `commitDepth`: limits to N most recent
- [ ] Check best practices:
- Enable "Require linear history" in branch protection rules
- Enable "Require signed commits" in branch protection rules
- Enable "Require signed web commits" in branch protection rules
```
{
"LABEL": {
"name": "title/description needs formatting",
"color": "EEEEEE"
},
"CHECKS": {
"prefixes": ["fix: ", "feat: "],
"regexp": "docs\\(v[0-9]\\): ",
"regexpFlags": "i",
"ignoreLabels" : ["dont-check-PRs-with-this-label", "meta"]
},
"MESSAGES": {
"success": "All OK",
"failure": "Failing CI test",
"notice": ""
}
}
```
## Permissions
- 'contents': read : This allows the action to list commits of the repository.
- 'pull-requests': read : This allows the action to list the commits in a Pull Request.
## Inputs
- `config`: `Path to commit lint config'
- 'debug':
- 'dry-run':
- 'download-dependencies': Experimental - use node to download commitlint config dependency (eg. @commitlint/config-conventional) Default : 'ignore'
- 'timeout': Change the default timeout for the action (in s). Default : '25'
- 'body': Pass the body of the PR to the commit as the body. Default : 'false'
- 'token': GitHub Token for fetching commits using the GitHub API
- 'fail_on_error': Whether the GitHub Action should fail if commitlint detects an issue.
- 'configuration_path': path to action config. Default : '.github/pr-merge-commitlint.json'
- 'pass_on_octokit_error': ... Default: 'false'
- 'commitlint_version': ... Default : 'latest'
- 'pr_title': PR title. Default : ${{ github.event.pull_request.title }}
- 'config_file': Commitlint configuration file path. Default : null
- 'config': Commitlint configuration plaintext, ignored if config_file provided. Default : module.exports = { extends: ["@commitlint/config-conventional"] };
- 'node_modules': Path to node_modules directory. Default : null
- 'node_version': Node.js version, ignored if node_modules provided. Default : v20.15.1
- 'commitlint_version': Commitlint version, ignored if node_modules provided. Default : ^19.5.0
- 'additional_node_dependencies': Additional node dependencies, ignored if node_modules is provided. Default : @commitlint/config-conventional@^19.5.0
- 'base_ref': The source of pull request that triggered this workflow (required for pull requests). Default : ${{ github.base_ref }}
- 'head_ref': The destination of the pull request that triggered this workflow (required for pull requests). Default : ${{ github.head_ref }}
- 'target_ref': The Github SHA of the event that triggered this workflow. Default : ${{ github.sha }}
- 'ref_name': The name of the ref (branch or tag) of the event that triggered this workflow (required for pushes). Default : ${{ github.ref_name }}
- 'ref_type': The ref type of the event that triggered this workflow (required for pushes). Only branch refs are validated. Default : ${{ github.ref_type }}
- 'extra_config': An optional newline-separated list of commitlint-config npm packages to install. Default : ''
## Outputs
- 'lint-status'
- 'lint-details'
- 'exit_code'
- 'stdout'
- 'stderr'
- 'pr_title'
- 'pr_number'
- 'valid'
- 'outcomes': structured Array as JSON string of the validation feedback
- 'report': The formatted string report of the validation outcomes'
## Resources
- [wagoid](wagoid/commitlint)
- [commitlint-prlint](https://github.com/marketplace/actions/commitlint-prlint)
- [conventional-commitlint](https://github.com/marketplace/actions/conventional-commitlint)
- [commitlint](https://commitlint.js.org/)
- [conventionalcommits](https://www.conventionalcommits.org/)
- [GitHub: Require linear history](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches#require-linear-history)
- [wagoid/commitlint-github-action](https://github.com/wagoid/commitlint-github-action)
- [Git Rebase vs Merge](https://www.atlassian.com/git/tutorials/merging-vs-rebasing)
Contributor guide
Assessment
This issue has not been assessed yet.