wagoid / commitlint-github-action

Lints Pull Request commits with commitlint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add action to local workflow using pre-commit

medmouine-beneva opened this issue · comments

Hi, is there anyway to setup the same rules for a local development environment as pre-commit? The main goal is to ensure the check passes before submitting it to the workflow.

Thanks!

Hi @medmouine-beneva! For that you can install commitlint CLI and use a pre-commit tool such as husky for example. In the getting started of commitlint they explain how to do it. Let me know if that doesn't work 💪

@wagoid Thanks for the quick reply. I have tried that but I am not sure how to integrate the action with it, should I just set the commitlint.config.js as input and everything should work fine?

@medmouine-beneva yes! @commitlint/cli will also take the commitlint.config.js of your repo when running checks. If your repo doesn't have a commitlint.config.js file, you will need to create one with the following config:

module.exports = { extends: ['@commitlint/config-conventional'] }

That's because this action uses this config by default if you repo doesn't have any commitlint config file 👍

@wagoid Done! thanks for the help!

Should I open a PR with some docs on how exactly I achieved it? basically I added the commitlint.config.js to the .husky folder and edited the hook to use global dependencies for commitlint and its dependencies.

@medmouine-beneva ideally it would be better to have the commitlint dependencies in devDependencies of your package.json instead, so that all developers don't need to install it globally and you're sure everyone runs the same version.
Regarding commitlint.config.js, you can add to the same folder that your package.json is, @commitlint/cli will find it automatically 🚀
A PR with docs would definitely be appreciated! ✍️ ❤️

@wagoid I opted for global deps because the repo is not setup for npm/yarn dependencies, we use other scripting tools for now, with which I added a step installing all the globals.

I will open a PR on my personal account @medmouine asap. Thanks for the help and keep up the great work!