Skip to content

docs: add note about CircleCI config #1141

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

Merged
merged 1 commit into from
Jun 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions docs/guides-ci-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This guide assumes you have a already configured `commitlint` for local usage.

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

## Travis

```bash
# Install and configure if needed
npm install --save-dev @commitlint/travis-cli
Expand All @@ -20,4 +22,57 @@ script:
- commitlint-travis
```

## CircleCI

It's just a simple example of how CircleCI configuration file could look like to validate last commit message

```yml
version: 2
defaults:
working_directory: ~/project
docker:
- image: circleci/node:latest

jobs:
setup:
<<: *defaults
steps:
- checkout
- restore_cache:
key: lock-{{ checksum "package-lock.json" }}
- run:
name: Install dependencies
command: npm install
- save_cache:
key: lock-{{ checksum "package-lock.json" }}
paths:
- node_modules
- persist_to_workspace:
root: ~/project
paths:
- node_modules

lint_commit_message:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: Define environment variable with lastest commit's message
command: |
echo 'export COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")' >> $BASH_ENV
source $BASH_ENV
- run:
name: Lint commit message
command: echo "$COMMIT_MESSAGE" | npx commitlint

workflows:
version: 2
commit:
jobs:
- setup
- lint_commit_message: { requires: [setup] }
```

?> 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)