Skip to content

Commit acb4aff

Browse files
authored
docs(ci): add GitHub Actions section (#3558)
* docs: add link from README * docs(ci): add GitHub Actions section
1 parent 36bd6ea commit acb4aff

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ A number of shared configurations are available to install and use with `commitl
160160

161161
> ⚠️ If you want to publish your own shareable config then make sure it has a name aligning with the pattern `commitlint-config-emoji-log` or `commitlint-config-your-config-name` — then in extend all you have to write is `emoji-log` or `your-config-name`.
162162
163+
## Documentation
164+
165+
Check the [main website](https://commitlint.js.org/).
166+
163167
## API
164168

165169
- Alternative, programmatic way to interact with `commitlint`

docs/guides-ci-setup.md

+41
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,47 @@ This guide assumes you have already configured `commitlint` for local usage.
66

77
Follow the [Getting Started](./?id=getting-started) for basic installation and configuration instructions.
88

9+
## GitHub Actions
10+
11+
An example of how a GitHub Actions workflow could validate the last commit message or all commit messages inside a Pull Request:
12+
13+
```yml
14+
name: CI
15+
16+
on: [push, pull_request]
17+
18+
jobs:
19+
commitlint:
20+
runs-on: ubuntu-22.04
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Install required dependencies
24+
run: |
25+
apt update
26+
apt install -y sudo
27+
sudo apt install -y git curl
28+
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
29+
sudo DEBIAN_FRONTEND=noninteractive apt install -y nodejs
30+
- name: Print versions
31+
run: |
32+
git --version
33+
node --version
34+
npm --version
35+
npx commitlint --version
36+
- name: Install commitlint
37+
run: |
38+
npm install conventional-changelog-conventionalcommits
39+
npm install commitlint@latest
40+
41+
- name: Validate current commit (last commit) with commitlint
42+
if: github.event_name == 'push'
43+
run: npx commitlint --from HEAD~1 --to HEAD --verbose
44+
45+
- name: Validate PR commits with commitlint
46+
if: github.event_name == 'pull_request'
47+
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
48+
```
49+
950
## Travis
1051
1152
```bash

0 commit comments

Comments
 (0)