Steps and commands
The step forms cigen understands, and reusable commands.
Steps
A job’s steps run in order, after the checkout step that cigen adds.
# .cigen/config.yml
provider: github
# .cigen/workflows/ci/jobs/lint.yml
image: node:24
steps:
# A shell command
- run: npm ci
# A shell command with options
- run:
name: Lint
command: npm run lint
env:
CI: 'true'
if: github.event_name == 'pull_request'
# A GitHub Action
- uses: actions/upload-artifact@v4
with:
name: lint-report
path: reports/lint.json
| Form | GitHub Actions | CircleCI |
|---|---|---|
- run: <command> |
A run step |
A run step |
- run: {name, command, env, if} |
A named run step |
A named run step |
- uses: <action> with with: and if: |
The action | Passed through, and CircleCI rejects it |
A command name, such as - setup_db |
The command’s steps | The command |
A CircleCI step, such as - store_artifacts |
An error | Passed through unchanged |
On GitHub Actions, a step that’s neither a GitHub step nor a command is an error that names the job and the step, and says what to use instead where there’s an equivalent:
# cigen.yml
# error: `restore_cache` is a CircleCI step. On GitHub, use the `actions/cache` action
provider: github
workflows:
ci:
jobs:
test:
image: ubuntu-latest
steps:
- restore_cache:
keys: [deps-v1]
- run: make test
Other step keys
A step keeps every key you give it. Keys cigen doesn’t model, such as id, shell, continue-on-error or CircleCI’s
when, go to the provider unchanged and are part of the job’s hash, so changing one makes the job run. A key can sit
beside run: or inside it:
# cigen.yml
provider: github
workflows:
ci:
jobs:
lint:
image: node:24
steps:
- run: npm ci
name: Install
- run:
name: Lint
command: npm run lint
shell: bash
- name: Upload the report
id: upload
uses: actions/upload-artifact@v4
with:
name: lint-report
path: reports/lint.json
continue-on-error: true
The GitHub provider fails on a key a GitHub step can’t have, and names the job, the step and the keys it can have:
# cigen.yml
# error: `when` is not a GitHub step key
provider: github
workflows:
ci:
jobs:
test:
image: ubuntu-latest
steps:
- run: make test
when: always
Commands
A command is a named list of steps that jobs can share. Define it under commands in cigen.yml, or in
.cigen/commands/<name>.yml:
# cigen.yml
provider: circleci
commands:
install_gems:
description: Install Ruby gems
parameters:
path:
type: string
default: vendor/bundle
steps:
- run: bundle config set path << parameters.path >>
- run: bundle install
workflows:
ci:
jobs:
test:
image: cimg/ruby:3.4
steps:
- install_gems
- run: bundle exec rspec
On CircleCI, commands become CircleCI commands, with their parameters. On GitHub Actions, which has no commands, a
step that names a command is replaced by the command’s steps (and the steps of any command it uses), with
<< parameters.x >> filled in from the values the step gives or the parameter’s default. Pass values the CircleCI way:
# fragment
steps:
- install_gems # path is vendor/bundle, the default
- install_gems:
path: gems
On GitHub these are errors: a parameter with no value and no default, a value for a parameter the command doesn’t
declare, a parameter of type steps, a command that uses itself, and << pipeline.x >>.
A command a job uses, and every command that command uses, is part of the job’s hash: changing a command reruns the jobs that use it, and no others.