I added the step to run
npx commitlint --from=HEAD~1 in my workflow:
But got the error:
Error: fatal: ambiguous argument 'HEAD~1..HEAD': unknown revision or path not in the working tree.
I discovered that
actions/[email protected] does a shallow checkout by default, which means it only checks out the last commit:
- uses: actions/[email protected] with: fetch-depth: 1
To fetch the entire commit history, set
- uses: actions/[email protected] with: fetch-depth: 0
Alternatively, a positive integer can be passed to fetch N commits.
However, if a shallow checkout is permissible (
fetch-depth: 1), then update
commitlint to lint only the last commit message:
- run: git log -1 --pretty=format:"%s" | npx commitlint
Check out “Migrate Travis CI to GitHub Actions (Node.js)” for more information on how to set up GitHub Actions.