Skip to content

Commit 3d4cf85

Browse files
docs: add note about CircleCI config (#1141)
1 parent 8c2b352 commit 3d4cf85

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

docs/guides-ci-setup.md

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

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

9+
## Travis
10+
911
```bash
1012
# Install and configure if needed
1113
npm install --save-dev @commitlint/travis-cli
@@ -20,4 +22,57 @@ script:
2022
- commitlint-travis
2123
```
2224
25+
## CircleCI
26+
27+
It's just a simple example of how CircleCI configuration file could look like to validate last commit message
28+
29+
```yml
30+
version: 2
31+
defaults:
32+
working_directory: ~/project
33+
docker:
34+
- image: circleci/node:latest
35+
36+
jobs:
37+
setup:
38+
<<: *defaults
39+
steps:
40+
- checkout
41+
- restore_cache:
42+
key: lock-{{ checksum "package-lock.json" }}
43+
- run:
44+
name: Install dependencies
45+
command: npm install
46+
- save_cache:
47+
key: lock-{{ checksum "package-lock.json" }}
48+
paths:
49+
- node_modules
50+
- persist_to_workspace:
51+
root: ~/project
52+
paths:
53+
- node_modules
54+
55+
lint_commit_message:
56+
<<: *defaults
57+
steps:
58+
- checkout
59+
- attach_workspace:
60+
at: ~/project
61+
- run:
62+
name: Define environment variable with lastest commit's message
63+
command: |
64+
echo 'export COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")' >> $BASH_ENV
65+
source $BASH_ENV
66+
- run:
67+
name: Lint commit message
68+
command: echo "$COMMIT_MESSAGE" | npx commitlint
69+
70+
workflows:
71+
version: 2
72+
commit:
73+
jobs:
74+
- setup
75+
- lint_commit_message: { requires: [setup] }
76+
```
77+
2378
?> Help yourself adopting a commit convention by using an interactive commit prompt. Learn how to use `@commitlint/prompt-cli` in the [Use prompt guide](guides-use-prompt.md)

0 commit comments

Comments
 (0)