What CI/CD is and how a pipeline works
CI/CD is the practice of building, testing and deploying code automatically on every change. Continuous integration (CI) builds and tests every push and pull request. Continuous delivery (CD) deploys a verified build to staging and production.
A pipeline catches a bug in the very change that introduced it and keeps code that failed its checks out of production. It runs only the checks written into it: without tests, CI proves only that the code builds. GitHub Actions also runs a workflow on other repository events — for example, to label a new issue.
A pipeline is a chain of stages. A push to a branch triggers a build and tests, the verified build is saved as an artifact and deployed to staging, and to production — after manual approval. If a job fails at some stage, the later stages do not run and the pipeline stops.
when: manual.How GitHub Actions and GitLab CI are organised
- GitHub Actions: an event — a push, a pull request, a schedule or a manual run — triggers a workflow. A workflow consists of jobs, and a job consists of steps: the
runcommand or a ready-made action added withuses. - Jobs in a workflow run in parallel by default; the order is set by
needsdependencies. A job’s steps run on a single runner, one after another by default, and see the same files. - GitLab CI: a pipeline consists of stages and jobs. Stages run one after another, jobs of the same stage run in parallel, and
needsstarts a job without waiting for the stage to finish. - A runner is a machine that executes a job — one job at a time. Both systems provide cloud runners on Linux, Windows and macOS, and both accept self-hosted runners.
- The pipeline definition lives in the repository: in GitHub — any number of
.ymlor.yamlfiles in the.github/workflows/directory, in GitLab — a.gitlab-ci.ymlfile at the root of the project.
GitHub Actions or GitLab CI
| Feature | GitHub Actions | GitLab CI |
|---|---|---|
| Where the code lives | a repository on GitHub | a project on GitLab.com or on your own GitLab server |
| Pipeline file | .github/workflows/*.yml, as many files as you like | .gitlab-ci.yml at the root; parts are pulled in with include |
| Job order | in parallel; the order is set with needs | stages run in sequence; needs bypasses the stages |
| Runners | cloud Linux, Windows, macOS; your own self-hosted ones | GitLab.com runners on Linux, Windows, macOS; your own GitLab Runner |
| Ready-made blocks | actions from GitHub Marketplace, reusable workflows | components from the CI/CD Catalog, templates, include |
| Secrets and environments | repository, environment and organisation secrets; environments with deployment approvals | CI/CD variables with the protected and masked flags; protected environments (Premium, Ultimate) |
Choose the system of the platform where your repository already lives: GitHub Actions is built into GitHub, GitLab CI into GitLab. Neither needs a separate CI server. Jenkins is a standalone automation server: its pipeline is described in a Jenkinsfile, which also lives in the repository.
What you need to know in advance
- Git: branches, commits, pull request and merge request — see the Git reference, sections “Branches and HEAD” and “Branching workflows”.
- YAML: indentation, lists and dictionaries — every pipeline file is made of them.
- The Linux command line and Bash:
runandscriptsteps are shell commands. - Docker: jobs often run in containers, and the outcome of a pipeline is an image — see the Docker reference, sections “Images and registries” and “Dockerfile instructions”.
Section sources
the section is written from these pages- Understanding GitHub Actionsdocs.github.com/en/actions/get-started/understand-github-actions(opens in a new tab)
- CI/CD pipelinesdocs.gitlab.com/ci/pipelines/(opens in a new tab)
- Get started with GitLab CI/CDdocs.gitlab.com/ci/(opens in a new tab)
- Pipelinejenkins.io/doc/book/pipeline/(opens in a new tab)