-
Notifications
You must be signed in to change notification settings - Fork 934
Document use of commitlint as a github action (possible own CLI in the future) #586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes, a Github action would be cool. Want to lend a hand with this? |
I made this but have no idea if it works, since i'm not in the beta https://github.com/bennypowers/commitlint-gh-actions |
Nice, I can give it a try. |
Added you to the repo. Do your worst 💃 |
I'm accepted in the beta, so whatever happens, I can try it out too 😄 Also building some actions for Expo, but ran into some issues and trying to fix it with the GH team. I think we also need to discuss where this will be hosted. We can do something like |
As a small side note, I would definitely recommend using the full LTS node version (
With these two minor, but good changes, the action covers more edge cases. I believe that was the main purpose of actions, make it simple and easy to use for everyone. Or do you have a different opinion about this @bennypowers? |
Agreed, I think it would be nice to have actions for CI environments. |
I think we should solve #613 and zero config before doing this right? That way, we can simply create an action with everything set to default. If projects have their own conventions, they simply need to add a |
@byCedric I have no strong opinion regarding node versions. probably newer is better. I can add you to the repo also |
Thanks! I'm trying to help out the guys at |
Ok, I published this https://github.com/marketplace/actions/commitlint-cli Haven't tried it out just yet 🙈 |
I've created a github action for this that doesn't require any setup, if you want to have a look: https://github.com/marketplace/actions/commit-linter I tried using @bennypowers's action but got some issues and ended up creating another one, as explained here I am already using in some projects, feel free to use it too and let me know if anything goes wrong 😃 |
I think you can also just call @commitlint/cli for this and get number of commits from PR event on: [pull_request]
jobs:
lint-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
# we actually need "github.event.pull_request.commits + 1" commit
fetch-depth: 0
- uses: actions/[email protected]
# or just "yarn" if you depend on "@commitlint/cli" already
- run: yarn add @commitlint/cli
- run: yarn run commitlint --from HEAD~${{ github.event.pull_request.commits }} --to HEAD |
I was looking to lint all commit messages of a pull request and ended up using these steps:
The above step:
P.S |
@arznaar can you help me better understand the need for |
As we lint the whole PR history, we usually need more than 1 commit and in their readme, action/checkout fetches only one commit (https://github.com/actions/checkout/blob/592cf69a223b04e75ddf345919130b91010eb2a6/README.md):
Not sure why my solution above would be limited to 20 commits, as I specifically avoid it by using |
Thanks @eladchen. Perhaps I'll just deny PRs with more than 20 commits in them hahah. |
Any change to get this sorted? The documentation page from https://commitlint.js.org/#/guides-ci-setup does include guides only for Travis and Circle CI but fails to document how to setup Github Actions, a CI that is likely more popular than all others combined. I was able to identify at least 3 different third party github actions on https://github.com/marketplace?query=commitlint but I do think that documenting a more or less official/recommended way of implementing the CI part would be highly useful for others. AFAIK, it would ok to endorse an action implemented by someone else instead of not doing anything. We can always look into publishing our own action later. |
Happy for a PR to at least point at a preferred 3rd party solution and document. |
@escapedcat How about a title like "Document use of commitlint as a github action". It should be generic enough. BTW, For the moment I picked the one with most stars (~100) but I need to validate that it really prevents bad commits from passing. |
Hi, nothing was added to the doc, do you need some help to at least reference solutions and/or this solution #2568 (comment) |
@ajubin yeah, happy if you could provide a PR to the docs here: |
@mangkoran It's been a while since I've posted that answer. As far as I remember it was needed to ensure the commit we're using as a ref would be included in the range of commits being processed by commitlint (inclusive/exclusive) |
@eladchen Indeed you posted it a while ago, yet still did the trick for many people :D So the "^" is |
It's a git syntax:
|
I see. Thank you! |
I assume this has been solved: https://commitlint.js.org/#/guides-ci-setup?id=github-actions |
Expected Behavior
Provide a github actions cli just like
commitlint-travis
.Context
It should easy setup for running commitlint as part of a github actions setup.
The text was updated successfully, but these errors were encountered: