Skip to content
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

Update circleci ci-setup.md #3989

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
74 changes: 39 additions & 35 deletions docs/guides/ci-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,52 +70,56 @@ script:
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
version: 2.1

executors:
my-executor:
docker:
- image: cimg/node:current
working_directory: ~/project

jobs:
setup:
<<: *defaults
executor: my-executor
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
- 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
executor: my-executor
steps:
- checkout
- attach_workspace:
at: ~/project
- run:
name: Define environment variable with latest 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
- checkout
- attach_workspace:
at: ~/project
- run:
name: Define environment variable with latest 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
version: 2.1
commit:
jobs:
- setup
- lint_commit_message: { requires: [setup] }
- setup
- lint_commit_message:
requires:
- setup
```

## GitLab CI
Expand Down