Bookmarks
ReferenceDevOps & cloudVerified

CI/CD

CI/CD — the practice and tools for automatically building, checking and deploying code. The reference covers: GitHub Actions, GitLab CI, runners, artifacts, secrets and OIDC.

checked 1 Nov · next check 8 Nov · 58 min read

Sections
13
Reading
58 min
Current version
19.5.3
Written from
docs.github.com/en/actions

Check status of the reference

Verified 1 Nov · next check 8 Nov

The sections were compared with the release notes, the check found nothing, and all source links respond.

  1. Verified
  2. Scheduled check

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.

Manual approval in GitHub Actions — environments with required reviewers, in GitLab CI — a job with 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 run command or a ready-made action added with uses.
  • Jobs in a workflow run in parallel by default; the order is set by needs dependencies. 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 needs starts 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 .yml or .yaml files in the .github/workflows/ directory, in GitLab — a .gitlab-ci.yml file at the root of the project.

GitHub Actions or GitLab CI

FeatureGitHub ActionsGitLab CI
Where the code livesa repository on GitHuba 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 orderin parallel; the order is set with needsstages run in sequence; needs bypasses the stages
Runnerscloud Linux, Windows, macOS; your own self-hosted onesGitLab.com runners on Linux, Windows, macOS; your own GitLab Runner
Ready-made blocksactions from GitHub Marketplace, reusable workflowscomponents from the CI/CD Catalog, templates, include
Secrets and environmentsrepository, environment and organisation secrets; environments with deployment approvalsCI/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: run and script steps 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

Cheat sheet

Typical GitHub Actions and GitLab CI constructs side by side: how to write the same thing in a workflow and in .gitlab-ci.yml. Each row is explained in its own section; replace test, deploy and DEPLOY_TOKEN with your own names.

Running a pipeline

TaskGitHub ActionsGitLab CI
Run on push and pull requeston: [push, pull_request]a pipeline on push is always created; for a merge request — if: $CI_PIPELINE_SOURCE == "merge_request_event" in rules
Only the main branchon: { push: { branches: [main] } }rules: [ { if: $CI_COMMIT_BRANCH == "main" } ]
Only when src/ changespaths: ["src/**"] on the eventrules: [ { changes: ["src/**/*"] } ]
On a scheduleschedule: [ { cron: "0 3 * * 1" } ], the time is in UTC by defaultschedules in the UI (Pipeline schedules)
Manual runon: workflow_dispatchthe “New pipeline” button in “Build → Pipelines”
Skip for a commit[skip ci] in the commit message[skip ci] in the commit message

Jobs and steps

TaskGitHub ActionsGitLab CI
Where to runruns-on: ubuntu-latestimage: python:3.15, the runner is picked by tags
Commandrun: pytestscript: [pytest]
Ready-made blockuses: actions/checkout@v7include: [ { component: $CI_SERVER_FQDN/my-org/ci/lint@1.0 } ]
Job after another jobneeds: buildneeds: [build]
Version matrixstrategy: { matrix: { python: ["3.14", "3.15"] } }parallel: { matrix: [ { PYTHON: ["3.14", "3.15"] } ] }
Conditionif: github.ref == 'refs/heads/main'rules: [ { if: $CI_COMMIT_BRANCH == "main" } ]
Allow failurecontinue-on-error: trueallow_failure: true
Time limittimeout-minutes: 30timeout: 30 minutes
Database for testsservices: with image: postgres:18services: [postgres:18]

Data, images, secrets and deployment

TaskGitHub ActionsGitLab CI
Pass files to the next jobactions/upload-artifact@v7, then actions/download-artifact@v8artifacts: { paths: [dist/] }
Dependency cacheactions/cache@v6 or cache: pip in actions/setup-python@v7cache: { key: { files: [requirements.txt] }, paths: [.cache/pip] }
Build and publish an imagedocker/build-push-action@v7 with push: truedocker build and docker push with the docker:29-dind service
Secret in a stepenv: { TOKEN: ${{ secrets.DEPLOY_TOKEN }} }the $DEPLOY_TOKEN variable from “Settings → CI/CD → Variables”
Cloud access without keyspermissions: { id-token: write }id_tokens: on the job
Environmentenvironment: productionenvironment: production
Deployment approvalrequired reviewers on the environmentwhen: manual on the deploy job
One deployment at a timeconcurrency: productionresource_group: production

GitHub Actions contexts and variables

What you needExpression and environment variable
Branch or tag name${{ github.ref_name }}, $GITHUB_REF_NAME
Full ref${{ github.ref }} (refs/heads/main), $GITHUB_REF
Commit SHA${{ github.sha }}, $GITHUB_SHA
Triggering event${{ github.event_name }}, $GITHUB_EVENT_NAME
Repository in the form “owner/name”${{ github.repository }}, $GITHUB_REPOSITORY
Who triggered the run${{ github.actor }}, $GITHUB_ACTOR
Run number${{ github.run_number }}, $GITHUB_RUN_NUMBER
Runner OS${{ runner.os }}, $RUNNER_OS
Pull request branches${{ github.head_ref }} and ${{ github.base_ref }}
Secret and settings variable${{ secrets.DEPLOY_TOKEN }}, ${{ vars.REGISTRY }}
Output of another job${{ needs.build.outputs.version }}
Input of a manual run${{ inputs.target }}

Predefined GitLab CI variables

What you needVariable
Branch; not available in merge request and tag pipelines$CI_COMMIT_BRANCH
Branch or tag$CI_COMMIT_REF_NAME
Branch or tag for URLs and names: lowercase letters, up to 63 bytes$CI_COMMIT_REF_SLUG
Tag; only in tag pipelines$CI_COMMIT_TAG
Commit SHA and its first 8 characters$CI_COMMIT_SHA, $CI_COMMIT_SHORT_SHA
Default branch$CI_DEFAULT_BRANCH
What triggered the pipeline$CI_PIPELINE_SOURCE: push, merge_request_event, schedule, web
Merge request number$CI_MERGE_REQUEST_IID
Directory with the code$CI_PROJECT_DIR
Project image registry$CI_REGISTRY, $CI_REGISTRY_IMAGE
Registry login from a job$CI_REGISTRY_USER, $CI_REGISTRY_PASSWORD
Job token for the API$CI_JOB_TOKEN

Section sources

the section is written from these pages

Workflow syntax and .gitlab-ci.yml

A workflow is a YAML file in the .github/workflows/ directory: the on key sets the trigger events, jobs the jobs; in each job, runs-on picks a runner and steps lists the steps. In GitLab CI the same is described by a single .gitlab-ci.yml file: stages for the stages and jobs with a script.

The reference example checks a Python project on every push to main and on every pull request: Ruff checks the code and pytest runs the tests.

yaml.github/workflows/ci.yml
name: CIon:  push:    branches: [main]  pull_request:permissions:  contents: readenv:  PYTHONUNBUFFERED: "1"jobs:  test:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v7      - uses: actions/setup-python@v7        with:          python-version: "3.15"          cache: pip      # ruff and pytest are listed in requirements.txt      - run: pip install -r requirements.txt      - name: Lint        run: ruff check .      - name: Tests        run: pytest
  • name — the workflow name shown on the “Actions” tab; without it the file path is shown.
  • on — the trigger events: here, pushes to main and any pull request.
  • permissions — the permissions of the GITHUB_TOKEN token: contents: read only allows reading the code, and any permission not listed becomes none.
  • env — environment variables for the steps of all jobs; an env on a job or step overrides the variable of the same name.
  • jobs.test — a job with the identifier test; an identifier starts with a letter or _.
  • runs-on — the runner label; steps — the steps, which run in order.
  • uses brings in an action, with passes parameters to it, and run runs shell commands.

Top-level keys

KeyWhat it sets
namethe workflow name
run-namethe name of a specific run, may include an expression: Deploy by @${{ github.actor }}
ontrigger events and filters
permissionsthe GITHUB_TOKEN permissions for all jobs
envenvironment variables for the steps of all jobs
defaultsdefault shell and working directory for run steps
concurrencya group where only one run goes at a time
cache-modejob access to the Actions cache: read, write, write-only, none
jobsthe jobs of the workflow

Expressions, contexts and if

The ${{ … }} expression is evaluated by GitHub itself, before the value reaches a command or a parameter. An expression can use the contexts — github, env, vars, secrets, matrix, needs, steps, runner, inputs — along with literals, the operators ==, !=, &&, ||, ! and functions. Strings inside an expression are written in single quotes, and string comparison is case-insensitive.

yamlworkflow fragment
jobs:  deploy:    if: github.ref == 'refs/heads/main'    runs-on: ubuntu-latest    steps:      - run: echo "Branch $GITHUB_REF_NAME"      - name: Show the report on failure        if: failure()        run: cat report.txt
  • Inside if you can omit ${{ }}: GitHub always evaluates it as an expression. The exception is a condition that starts with !: in YAML that is an indicator character, so write if: ${{ !cancelled() }}.
  • Status functions: success() — the default, failure(), cancelled(), always(). To make a step run both on failure and on success but not on cancellation, use !cancelled(), not always().
  • Other functions: contains(), startsWith(), format(), join(), toJSON(), fromJSON(), hashFiles() and case(), which returns the value of the first condition that is true.
  • A context property that does not exist yields an empty string, not an error.

Default values and concurrency

defaults.run sets the shell and the working directory for all run steps. With shell: bash, GitHub runs bash --noprofile --norc -eo pipefail, and a step fails even on an error inside a pipeline of commands; without shell, it is bash -e on Linux.

yamlworkflow fragment
defaults:  run:    shell: bash    working-directory: ./appconcurrency:  group: ${{ github.workflow }}-${{ github.ref }}  cancel-in-progress: true

concurrency keeps a single run going in the group: a new run waits in the queue, and with cancel-in-progress: true it cancels the one in progress. This is how a push to a branch cancels the outdated check of the previous commit. The group is built from the workflow name and the ref, so runs of other workflows stay untouched. By default one run waits in the group and the next one replaces it; queue: max queues up to 100 runs but does not combine with cancel-in-progress: true.

Reusable workflows and composite actions

Jobs that repeat are factored out into a reusable workflow — an ordinary file in .github/workflows/ whose on contains workflow_call. It is called as a whole job via uses: inputs are passed in with, secrets in secrets; nesting goes up to ten levels. Steps that repeat are gathered into a composite action: a directory with an action.yml file, brought in by a uses step.

yaml.github/workflows/tests.yml
on:  workflow_call:    inputs:      python-version:        type: string        default: "3.15"jobs:  test:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v7      - uses: actions/setup-python@v7        with:          python-version: ${{ inputs.python-version }}      - run: pip install -r requirements.txt      - run: pytest
yaml.github/workflows/ci.yml
on: [push, pull_request]jobs:  tests:    uses: $/.github/workflows/tests.yml    with:      python-version: "3.14"    secrets: inherit

secrets: inherit passes all of the caller’s secrets to the called workflow; this is allowed within one organisation or enterprise. For a file in the same repository the documentation recommends writing $/.github/workflows/tests.yml; the ./.github/workflows/tests.yml form works too, and on GitHub Enterprise Server it is the only one that works. A workflow from another repository is referenced as OWNER/REPO/.github/workflows/FILE@REF, and the safest thing is to pin it to a commit SHA.

GitLab CI

In GitLab the pipeline is described by the .gitlab-ci.yml file in the project root. The global keys — stages, default, include, variables, workflow — set the behaviour of the whole pipeline, and the remaining top-level keys are jobs. Every job has a script or a trigger. The example mirrors the GitHub workflow: a check on every merge request and on a push to the default branch.

yaml.gitlab-ci.yml
workflow:  rules:    - if: $CI_PIPELINE_SOURCE == "merge_request_event"    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH stages:  - test  - deploy # deployment jobs live in a separate fileinclude:  - local: /ci/deploy.yml default:  image: python:3.15 lint:  stage: test  script:    - pip install ruff    - ruff check . tests:  stage: test  script:    - pip install -r requirements.txt    - pytest
  • workflow: rules decide whether a pipeline is created: here, for a merge request and for the default branch. The rules are checked in order until the first match; if none match, there is no pipeline. The same rules on an individual job decide whether the job itself gets into the pipeline.
  • stages — the order of the stages. Without it, .pre, build, test, deploy, .post apply, and a job without a stage lands in test.
  • include brings in other YAML files: local, project, remote, template, component. What is brought in is merged with .gitlab-ci.yml, and when names clash the main file wins.
  • default — values for all jobs: image, before_script, cache, retry and others. A key on the job itself replaces the default value entirely, without merging.
  • image — the container image in which the runner runs the script.

Section sources

the section is written from these pages

Triggers: when a pipeline runs

A trigger is an event that starts a workflow: push, pull_request, a schedule or a manual workflow_dispatch run. The branches, tags and paths filters narrow the run down to the branches and files you need, so the pipeline does not run needlessly.

yaml.github/workflows/ci.yml
on:  push:    branches: [main, "release/**"]    tags: ["v*"]    paths-ignore: ["docs/**", "**.md"]  pull_request:    branches: [main]  schedule:    # every Monday at 03:00 UTC    - cron: "0 3 * * 1"  workflow_dispatch:
EventWhen it firesWhat matters
pusha commit or tag is pushedthe branches, tags and paths filters; paths does not apply to tags
pull_requesta pull request is opened, updated or reopened: by default opened, synchronize, reopenedthe merge commit refs/pull/N/merge is checked; does not run on a merge conflict
pull_request_targetthe same pull request actionsruns in the context of the default branch, with secrets and a token with write permissions
workflow_dispatcha manual run: the button, gh workflow run, the APIthe file must be on the default branch
scheduleon a cron schedulethe time is in UTC by default, no more often than once every 5 minutes; only the default branch
releaserelease activity: published, created and otherswithout types it fires on every activity
workflow_runanother workflow has been requested, is running or has completedreceives secrets and a token with write permissions even when the originating workflow did not have them

Branch, tag and path filters

  • The branches, tags and paths filters take patterns: * matches any characters except /, ** matches any characters including /. Quote a pattern that starts with *, [ or !, otherwise YAML cannot parse the file.
  • The branches-ignore, tags-ignore and paths-ignore filters exclude matches. You cannot use them together with the paired filter: for mixed rules write the exclusions with ! in the main filter, and the order of the patterns matters.
  • When both branches and paths are set, the workflow runs only if both of them match.
  • For a pull request the list of changed files is built by comparing against the base branch. If more than 3000 files changed and the ones you need are not among the first 3000, the workflow will not run.
  • A workflow skipped by a filter or by a mark in the commit message leaves its checks in the “Pending” state, and a pull request with such a required check cannot be merged.
yamlworkflow fragment
on:  pull_request:    paths:      - "src/**"      - "!src/**/*.md"

To keep a commit from triggering a workflow, add [skip ci], [ci skip], [no ci], [skip actions] or [actions skip] to its message. The mark applies only to the push and pull_request events: for a pull request it is checked in the last commit.

Manual runs with inputs

workflow_dispatch adds a “Run workflow” button on the “Actions” tab when the file is on the default branch. Inputs are declared in inputs with the types string, boolean, choice, number and environment — at most 25 — and are read from the inputs context.

yaml.github/workflows/deploy.yml
on:  workflow_dispatch:    inputs:      target:        description: Where to deploy        type: choice        options: [staging, production]        default: staging      dry-run:        type: boolean        default: truejobs:  deploy:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v7      - run: ./deploy.sh "$TARGET" "$DRY_RUN"        env:          TARGET: ${{ inputs.target }}          DRY_RUN: ${{ inputs.dry-run }}
bashon your machine
gh workflow run deploy.yml \  -f target=production -f dry-run=false

Schedules and workflow chains

schedule takes POSIX cron with five fields and runs in UTC by default: 0 3 * * 1 is 08:00 in Tashkent. The timezone key sets the time zone as an IANA string. Runs at the start of an hour can be delayed, and in a public repository the schedule is disabled after 60 days without activity.

yamlworkflow fragment
on:  schedule:    - cron: "0 8 * * 1-5"      timezone: "Asia/Tashkent"

workflow_run starts a workflow after another one — for example, a deployment after a build. The event arrives whatever the outcome, so check conclusion; a chain of such runs is limited to three levels.

yaml.github/workflows/deploy.yml
on:  workflow_run:    workflows: [CI]    types: [completed]jobs:  deploy:    if: github.event.workflow_run.conclusion == 'success'    runs-on: ubuntu-latest    steps:      - run: echo "CI passed"

Events that a workflow triggers itself through GITHUB_TOKEN do not create new runs — this is how GitHub protects against infinite loops. The exceptions are workflow_dispatch and repository_dispatch; a pull request created with this token starts checks only after a user with write permissions approves it.

GitLab CI

In GitLab a pipeline for a push to a branch is created without any configuration, while a merge request pipeline is created only when the job’s rules or workflow:rules match $CI_PIPELINE_SOURCE == "merge_request_event". The rules key decides whether the job makes it into the pipeline: the rules are checked in order until the first match.

yaml.gitlab-ci.yml
workflow:  rules:    - if: $CI_PIPELINE_SOURCE == "merge_request_event"    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH    - if: $CI_COMMIT_TAG docs:  script: make docs  rules:    - changes:        - docs/**/*
  • if is a condition on variables: $CI_PIPELINE_SOURCE, $CI_COMMIT_BRANCH, $CI_COMMIT_TAG. The right-hand side of =~ is a regular expression.
  • changes adds the job if at least one of the files has changed. In new branches, tag pipelines, scheduled and manual runs changes is always true.
  • when: on_success by default, manual, delayed, always, never.
  • workflow:rules decide whether to create a pipeline at all: if no rule matches, there is no pipeline.
  • $CI_PIPELINE_SOURCE tells the sources apart: push, merge_request_event, schedule, web — a manual run from the UI, api, trigger.

Do not let a single job run on both push and merge request without workflow:rules: a push to a branch with an open merge request will create two pipelines at once. A merge request from a fork runs the pipeline in the fork itself, with the fork’s settings and variables.

Section sources

the section is written from these pages

Jobs, steps and matrices

A job is a set of steps, that runs on a single runner. The jobs of a workflow run in parallel by default and are independent of each other. needs defines the order, while the strategy.matrix matrix runs one job across several language or OS versions.

In the example, the build job goes first, followed in parallel by three test jobs for Python 3.13, 3.14 and 3.15 from the matrix. The deploy job waits for all of them via needs: test. If a job listed in needs fails or is skipped, the dependent jobs are skipped too, all along the chain. To make a job run whatever the outcome, give it if: ${{ always() }}.

With fail-fast: false, the other matrix jobs run to the end, but deploy still won’t start.
yaml.github/workflows/ci.yml
on: [push, pull_request]jobs:  build:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v7      - run: python -m pip install build && python -m build  test:    needs: build    runs-on: ubuntu-latest    strategy:      fail-fast: false      matrix:        python: ["3.13", "3.14", "3.15"]    steps:      - uses: actions/checkout@v7      - uses: actions/setup-python@v7        with:          python-version: ${{ matrix.python }}      - run: pip install -r requirements.txt      - run: pytest  deploy:    needs: test    if: github.ref == 'refs/heads/main'    runs-on: ubuntu-latest    steps:      - run: echo "Deploying"

Steps: uses and run

A step is either a ready-made uses action or run commands. Each step is a separate process: files in the working directory are visible to the steps that follow, while variables set with export are not. To pass a value on, write the line NAME=value to the $GITHUB_ENV file or to the step output $GITHUB_OUTPUT.

Step keyWhat it does
usesan action: OWNER/REPO@REF, a path in the repository ./… or an image `docker://IMAGE
withthe action’s input parameters
runshell commands; several lines as a | block
shellbash, sh, pwsh, python, cmd, powershell; bash -e by default on Linux and pwsh on Windows
working-directoryworking directory for `run
envenvironment variables of this step only
idstep name for steps.ID.outputs.NAME references
ifcondition for the step to run
continue-on-errora step failure doesn’t fail the job
timeout-minutesstep time limit, at most 360

The matrix

The matrix creates a job for every combination of values: two OSes and two versions make four jobs. The values are available in the matrix context, and a single run can have at most 256 matrix jobs. exclude removes combinations, include adds keys to matching combinations or adds new ones; include is applied after exclude.

yamljob fragment
runs-on: ${{ matrix.os }}strategy:  fail-fast: false  max-parallel: 4  matrix:    os: [ubuntu-latest, windows-latest]    python: ["3.14", "3.15"]    exclude:      - os: windows-latest        python: "3.14"    include:      - os: ubuntu-latest        python: "3.15"        coverage: true
KeyWhat it doesDefault
fail-fastwhen one job fails, cancels the other matrix jobstrue
max-parallelhow many matrix jobs run at the same timeas many as the runners allow
excluderemoves combinations; a partial match is enough—
includeadds keys to combinations or a new combination—
job continue-on-errorthis job failing doesn’t fail the whole workflowfalse

Conditions, time limits and job outputs

A job’s if is evaluated before the matrix is applied, so matrix is not available in it. A job’s timeout-minutes is 360 minutes by default. Outputs pass short strings between jobs: a step writes name=value to $GITHUB_OUTPUT, the job declares outputs, and the dependent job reads needs.JOB.outputs.NAME.

yamlworkflow fragment
jobs:  version:    runs-on: ubuntu-latest    outputs:      tag: ${{ steps.meta.outputs.tag }}    steps:      - id: meta        run: echo "tag=v$(date +%Y%m%d)" >> "$GITHUB_OUTPUT"  release:    needs: version    runs-on: ubuntu-latest    steps:      - run: echo "Release $TAG"        env:          TAG: ${{ needs.version.outputs.tag }}

A job output is up to 1 MB, and all outputs of a run together are up to 50 MB. An output in which the runner detected a secret is not passed on any further.

The job container and services

container runs all the steps of a job inside an image, while services brings up service containers alongside — for example, PostgreSQL for tests. If the steps run directly on the runner, a service is reachable at localhost and its published port; if the job itself runs in a container — by the service name. Job containers and services work only on Linux runners.

yamlworkflow fragment
jobs:  test:    runs-on: ubuntu-latest    services:      postgres:        image: postgres:18        env:          POSTGRES_PASSWORD: change-me        ports:          - 5432:5432        options: >-          --health-cmd pg_isready          --health-interval 10s          --health-retries 5    steps:      - uses: actions/checkout@v7      - run: pytest        env:          DATABASE_URL: postgresql://postgres:change-me@localhost/postgres

Steps in parallel

The steps of a job run one after another by default, but independent steps can run at the same time. parallel executes a group of steps at once and waits for all of them. background: true keeps a step running in the background until a wait or cancel step returns to it; a job can have up to 10 background steps at a time.

yamljob fragment
steps:  - uses: actions/checkout@v7  - parallel:      - run: npm run build:frontend      - run: npm run build:backend  - name: Start the API    id: api    run: python -m app    background: true  - run: pytest tests/e2e  - cancel: api

GitLab CI

In GitLab, a job is a top-level key with a script. Jobs of the same stage run in parallel, and the next stage waits for the previous one to finish successfully. needs starts a job right after the jobs listed, without waiting for the stage to end, while needs: [] starts it as soon as the pipeline is created.

yaml.gitlab-ci.yml
stages: [build, test, deploy] build:  stage: build  image: python:3.15  script:    - python -m pip install build    - python -m build test:  stage: test  needs: [build]  image: python:$PYTHON  parallel:    matrix:      - PYTHON: ["3.13", "3.14", "3.15"]  services:    - name: postgres:18      alias: db      variables:        POSTGRES_PASSWORD: change-me  variables:    DATABASE_URL: postgresql://postgres:change-me@db/postgres  script:    - pip install -r requirements.txt    - pytest deploy:  stage: deploy  needs: [test]  script: ./deploy.sh  rules:    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  • parallel: 5 runs five copies of the job, from test 1/5 to test 5/5; parallel:matrix runs one copy per combination of variables, up to 200 in total.
  • needs on a job with parallel waits for all of its copies.
  • services are containers next to the image; from the script, a service is reachable by its alias name.
  • allow_failure: true lets a job fail without failing the pipeline, timeout: 30 minutes overrides the project time limit, retry: 2 retries a failed job up to two times.
  • Job statuses: pending — waiting for a runner, running — in progress, manual — waiting for a manual start, skipped — skipped by conditions.

Section sources

the section is written from these pages

Runners

A runner is a machine that picks up a job from GitHub or GitLab, runs its steps and sends back the log and the status. A cloud runner provides a clean machine every time and needs no maintenance; a self-hosted runner is needed for special hardware, your own OS or access to the internal network.

A runner connects to the server by itself and waits for jobs. GitHub or GitLab puts a job into a queue, a free runner with matching labels picks it up and sends the log as it works. For each job, a GitHub cloud runner gets a new virtual machine, and the ubuntu-slim runner gets a new container.

It is the server that hands out the job, but the runner opens the connection: it connects and waits for jobs.

GitHub cloud runners

A cloud runner is selected by a label in runs-on. The -latest labels point to GitHub’s latest stable image and move to a new OS version over time. So that the image does not change unexpectedly, specify the version explicitly, for example ubuntu-24.04.

LabelSystemResources: public / private repository
ubuntu-latest, ubuntu-26.04, ubuntu-24.04, ubuntu-22.04Linux x644 CPU, 16 GB / 2 CPU, 8 GB
ubuntu-26.04-arm, ubuntu-24.04-armLinux arm644 CPU, 16 GB / 2 CPU, 8 GB
windows-latest, windows-2025, windows-2022Windows x644 CPU, 16 GB / 2 CPU, 8 GB
macos-latest, macos-26, macos-15macOS arm64 (M1)3 CPU, 7 GB
macos-26-intel, macos-15-intelmacOS Intel4 CPU, 14 GB
ubuntu-slimLinux x64 in a container1 CPU, 5 GB; a job — up to 15 minutes

Standard runners have a 14 GB SSD disk. In public repositories they are free without limits, in private ones they spend the minutes of the account. On Linux and macOS, sudo works without a password.

Your own GitHub runner

A runner is added in the repository’s or organisation’s “Settings → Actions → Runners → New self-hosted runner”. GitHub shows commands for the chosen OS: download and unpack the runner application, run the config script with the address and a token that is valid for an hour, and start the runner. A ready runner prints Listening for Jobs in the terminal.

During configuration, the runner receives the self-hosted label by default, as well as OS and architecture labels. In runs-on, list the labels you need, starting with self-hosted: the job will go to a runner that has every one of them.

yamljob fragment
runs-on: [self-hosted, linux, x64]

GitLab CI

GitLab.com has GitLab runners for Linux, Windows and macOS ready to use. A self-hosted runner is the GitLab Runner program: it is installed on a server separate from GitLab, registered, and an executor is chosen — the way the runner runs jobs.

ExecutorHow a job is runWhen to choose it
dockerin a clean container from the image image, with services servicesyou need the same clean environment for every job
kubernetesin a new pod of the cluster for every joba Kubernetes cluster already exists
docker-autoscaler, instanceon machines that are created on demand in the cloudthe load varies a lot
shelldirectly in the shell of the runner machine, without a clean environmentsimple builds; the executor is in maintenance mode, without new features
bashon a server, Ubuntu and Debian
REPO=https://packages.gitlab.com/install/repositories/runnercurl -L "$REPO/gitlab-runner/script.deb.sh" -o script.deb.shless script.deb.shsudo bash script.deb.shsudo apt install gitlab-runner

GitLab issues the registration token with the glrt- prefix when you create a project, group or instance runner; after registration the settings are stored in config.toml.

bashon the runner’s server
sudo gitlab-runner register \  --non-interactive \  --url "https://gitlab.com/" \  --token "$RUNNER_TOKEN" \  --executor "docker" \  --docker-image python:3.15 \  --description "docker-runner"

Labels are given to the runner when it is created, and a job selects a runner with the tags key: only a runner with all the listed labels will run it.

yaml.gitlab-ci.yml
build-arm:  tags: [arm64, docker]  script: make build

Section sources

the section is written from these pages

Artifacts and cache

An artifact — the files a job leaves behind: the build, test reports, logs. Jobs later in the same run and people after the run ends download them. A cache — files reused between runs, usually downloaded dependencies: it speeds up the pipeline, but it may disappear, and a job must be able to get by without it.

FeatureArtifactCache
What it storesthe job’s result: dist/, reports, logsdependencies: ~/.cache/pip, ~/.npm
Who reads itjobs of the same run and people after itlater runs and jobs
If it goes missingthere is no result — that is an errorthe job downloads the dependencies again
GitHub Actionsactions/upload-artifact, actions/download-artifactactions/cache or cache: in setup-*
GitLab CIartifacts:cache:
RetentionGitHub — retention-days, up to the repository setting; GitLab — expire_in or an instance settingGitHub deletes a cache that has not been accessed for 7 days

In a pipeline it looks like this: the build job uploads the dist/ directory as an artifact of the run, and deploy downloads it instead of building it again. A cache lives longer: the key is built from the hash of requirements.txt, and as long as the file does not change, every run restores ~/.cache/pip instead of downloading the packages.

An artifact belongs to a single run, while a cache carries over from run to run until the key changes.
yamlpart of a workflow
jobs:  build:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v7      - uses: actions/setup-python@v7        with:          python-version: "3.15"      - run: python -m pip install build && python -m build      - uses: actions/upload-artifact@v7        with:          name: dist          path: dist/          retention-days: 5  deploy:    needs: build    runs-on: ubuntu-latest    steps:      - uses: actions/download-artifact@v8        with:          name: dist          path: dist/      - run: ls dist/
  • name — the artifact name, without it — artifact; path — files and directories, glob patterns and exclusions through ! are allowed.
  • retention-days — the retention period in days, no more than the repository or organisation limit.
  • An artifact is immutable: upload changed files as a new artifact under a different name.
  • download-artifact without name downloads all artifacts of the run, each into a directory named after it.
  • upload-artifact returns the SHA-256 of the artifact in the digest output, and download-artifact verifies what it downloaded against it.

Dependency cache

actions/cache at the start of a job restores files by the key; if there was no exact match, it saves them under that key after the job succeeds. The key is built from the hash of a lock file: the dependencies changed — the key changed, and a new cache appears. restore-keys — fallback prefixes: on a miss, the freshest cache whose key starts the same way is restored.

yamljob steps
- uses: actions/cache@v6  with:    path: ~/.cache/pip    key: pip-${{ runner.os }}-${{ hashFiles('requirements.txt') }}    restore-keys: |      pip-${{ runner.os }}-- run: pip install -r requirements.txt

For pip, npm, Yarn, Gradle, Maven, Go and other package managers, the setup-* actions know how to cache on their own. In actions/setup-python, cache: pip is enough: the action finds requirements.txt and builds the key itself.

yamla job step
- uses: actions/setup-python@v7  with:    python-version: "3.15"    cache: pip

Limits and pitfalls

  • All caches of a repository together — up to 10 GB by default; over the limit GitHub evicts the least recently used ones. A key is up to 512 characters, and the contents of an existing cache never change: a new key is needed.
  • A run sees the caches of its own branch and of the default branch, and a pull request also sees the base branch. A cache created in a pull request is available only to re-runs of that PR.
  • If a cache is not restored, compare the key in the log with the saved one: the cache-hit output is true only on an exact match.
  • Workflows on low-trust events — pull_request_target, issue_comment, workflow_run — only read the caches of the default branch; the cache-mode key makes the access explicit.

GitLab CI

In GitLab, by default every job of the later stages downloads a job’s artifacts, and with needs or dependencies — only the listed ones. A cache is enabled with the cache key on a job and is stored where the runner is installed, or in S3 if a distributed cache is configured. Artifact and cache paths are set inside the project directory, so the pip cache is redirected there with the PIP_CACHE_DIR variable.

yaml.gitlab-ci.yml
build:  stage: build  script:    - python -m pip install build    - python -m build  artifacts:    paths:      - dist/    expire_in: 1 week test:  stage: test  variables:    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"  cache:    key:      files:        - requirements.txt    paths:      - .cache/pip  script:    - pip install -r requirements.txt    - pytest --junitxml=report.xml  artifacts:    reports:      junit: report.xml
  • expire_in — the retention period: 1 week, 30 days, never. Without it an instance setting applies, and the artifacts of the last successful pipeline of a branch are kept regardless of the period.
  • reports: junit hands GitLab a test report in the JUnit format; reports are uploaded whatever the job’s outcome.
  • cache:key:files builds the key from the contents of files: requirements.txt changed — a new cache is created.
  • Protected and unprotected branches do not share a cache by default.
  • The artifact archive on GitLab.com — up to 1 GB compressed.

Section sources

the section is written from these pages

Building and publishing images

The pipeline builds a Docker image from the repository’s Dockerfile and publishes it to a registry — GitHub Container Registry (ghcr.io), Docker Hub or a GitLab project’s registry. GitHub Actions has official Docker actions for this: registry login, tags and labels, and build and push.

The Dockerfile instructions, the BuildKit cache and multi-stage builds are described in the Docker reference, sections “Dockerfile and its instructions” and “Build: cache, multi-stage and secrets”. This section covers only the pipeline step that invokes them.

yaml.github/workflows/image.yml
name: Imageon:  push:    branches: [main]    tags: ["v*.*.*"]  pull_request:permissions:  contents: read  packages: writejobs:  image:    runs-on: ubuntu-latest    steps:      - uses: actions/checkout@v7      - id: meta        uses: docker/metadata-action@v6        with:          images: ghcr.io/${{ github.repository }}          tags: |            type=ref,event=branch            type=ref,event=pr            type=semver,pattern={{version}}            type=sha      - if: github.event_name != 'pull_request'        uses: docker/login-action@v4        with:          registry: ghcr.io          username: ${{ github.actor }}          password: ${{ secrets.GITHUB_TOKEN }}      - uses: docker/setup-buildx-action@v4      - uses: docker/build-push-action@v7        with:          context: .          push: ${{ github.event_name != 'pull_request' }}          tags: ${{ steps.meta.outputs.tags }}          labels: ${{ steps.meta.outputs.labels }}          cache-from: type=gha          cache-to: type=gha,mode=max
  • packages: write allows GITHUB_TOKEN to publish packages, so no separate token is needed to log in to ghcr.io: the username is github.actor, the password is GITHUB_TOKEN.
  • docker/metadata-action builds the image’s tags and labels from the event. type=ref,event=branch produces a tag from the branch name, type=semver the version from the Git tag v1.4.2, and type=sha a tag from the commit SHA.
  • In a pull request the image is built but not pushed: the registry login is skipped by the if condition and push is false. That way every PR checks the build.
  • docker/setup-buildx-action creates a separate Buildx builder. It is needed for the type=gha cache: the default docker driver supports this cache only with the containerd image store.
  • cache-from and cache-to with type=gha store the build layers in the GitHub Actions cache, and its limits apply. The gha backend is still experimental.

Tags: a commit SHA and a version instead of latest

Publish immutable tags — the commit SHA and the version from the Git tag. latest does not tell you which commit has been rolled out, and concurrent jobs overwrite it for one another.

Docker Hub instead of ghcr.io

For Docker Hub, store the Docker Hub token in the repository secret DOCKERHUB_TOKEN and the username in the variable DOCKERHUB_USERNAME. The registry key of docker/login-action is not needed, and the image name is “username/repository”. GitHub’s cloud runners are not subject to the Docker Hub limits on pulling and pushing images, self-hosted runners are.

yamla job step
- if: github.event_name != 'pull_request'  uses: docker/login-action@v4  with:    username: ${{ vars.DOCKERHUB_USERNAME }}    password: ${{ secrets.DOCKERHUB_TOKEN }}

GitLab CI

Every GitLab project has its own image registry. Its address is $CI_REGISTRY and the base of the image name is $CI_REGISTRY_IMAGE. The login and password for signing in from a job are $CI_REGISTRY_USER and $CI_REGISTRY_PASSWORD, and the password stays valid while the job runs. The docker commands are executed by the Docker-in-Docker service (docker:dind), and every job gets its own Docker daemon.

yaml.gitlab-ci.yml
build-image:  stage: build  image: docker:29-cli  services:    - docker:29-dind  variables:    DOCKER_HOST: tcp://docker:2376    DOCKER_TLS_CERTDIR: "/certs"    IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA  before_script:    - >-      echo "$CI_REGISTRY_PASSWORD" |      docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin  script:    - docker build --pull -t "$IMAGE" .    - docker push "$IMAGE"  rules:    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  • docker build --pull pulls a fresh version of the base image before the build.
  • For a tag based on the branch name use $CI_COMMIT_REF_SLUG: $CI_COMMIT_REF_NAME can contain /, which is not allowed in an image tag.
  • If several jobs need to log in, move the before_script with docker login into default.

Section sources

the section is written from these pages

Secrets, variables and OIDC

A secret is an encrypted variable for passwords and tokens: a workflow gets it only explicitly, via ${{ secrets.DEPLOY_TOKEN }}, and the log hides its value. Store settings that are safe to show in vars variables, and where possible get cloud access through OIDC — with no long-lived keys at all.

Levels and creating secrets

Secrets are created at three levels: the repository (“Settings → Secrets and variables → Actions”), an environment (“Settings → Environments”) and the organisation. An organisation secret has a policy: which repositories it is available to. An environment secret is available only to a job with that environment, and if the environment requires approval — only after it.

bashon your machine
gh secret set DEPLOY_TOKENgh secret set DEPLOY_TOKEN --env productiongh secret set SENTRY_DSN --org my-org --visibility allgh secret list

A secret in a step — via env

Pass a secret to an action via with, and to a program via the env environment variable. Do not substitute it into the command text: command-line arguments are visible to other processes through ps and end up in audit events. In a shell, take the variable in double quotes — secrets can contain special characters.

yamldon’t do this
- run: ./deploy.sh --token ${{ secrets.DEPLOY_TOKEN }}
yamlthe right way
- run: ./deploy.sh  env:    DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
  • An unset secret gives an empty string, not an error. A secret cannot be tested directly in if: assign it to a job-level env and test env.DEPLOY_TOKEN != ''.
  • A sensitive value that is not stored as a secret — for example, a token obtained in a step — hide in the log with echo "::add-mask::$VALUE".
  • Secrets other than GITHUB_TOKEN are not passed to a workflow run from a fork or to workflows on Dependabot events. They reach a reusable workflow only explicitly or through secrets: inherit.
  • A secret is up to 48 KB. Encrypt a large file with gpg, store it in the repository and keep only the passphrase in the secret.

GITHUB_TOKEN and permissions

Before each job GitHub issues it a GITHUB_TOKEN with access to its own repository. The token expires when the job ends and, on cloud-hosted runners, lives no longer than 6 hours. The token’s permissions are set by permissions at the workflow or job level: the listed ones get read, write or none, and everything else gets none. Grant contents: read by default and widen the permissions only where they are needed.

yaml.github/workflows/release.yml
on:  push:    tags: ["v*"]permissions:  contents: readjobs:  release:    runs-on: ubuntu-latest    permissions:      contents: write    steps:      - uses: actions/checkout@v7      - run: gh release create "$GITHUB_REF_NAME" --generate-notes        env:          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

OIDC instead of cloud keys

OpenID Connect (OIDC) removes long-lived cloud keys from secrets. In the cloud you set up trust for the GitHub OIDC provider with conditions on the token’s claims. At every run the job receives a signed JWT and exchanges it for a temporary key that is valid only while this job runs.

  1. A job with the id-token: write permission requests a token from the GitHub OIDC provider.
  2. The provider returns a JWT that is unique to this job. It contains the issuer iss (https://token.actions.githubusercontent.com), the audience aud and the subject sub, for example repo:octo-org/octo-repo:environment:production.
  3. The cloud sign-in step presents the JWT to the cloud provider.
  4. The cloud compares the token’s claims with the conditions of the role: which repository, branch or environment is asking for access.
  5. If the conditions match, the cloud issues a temporary key that is valid only until the end of the job.
  6. With this key the job deploys the application to the cloud.
yamlworkflow fragment
jobs:  deploy:    runs-on: ubuntu-latest    environment: production    permissions:      id-token: write      contents: read

The exchange of the token for a key is usually done by your cloud provider’s official sign-in action. The value of sub depends on where the job runs from:

Where the run comes fromValue of sub
A job with an environmentrepo:octo-org/octo-repo:environment:production
A pull request without an environmentrepo:octo-org/octo-repo:pull_request
A branchrepo:octo-org/octo-repo:ref:refs/heads/main
A tagrepo:octo-org/octo-repo:ref:refs/tags/v1.0.0

GitLab CI

In GitLab, secrets are stored in CI/CD variables of a project, group or instance (“Settings → CI/CD → Variables”), not in .gitlab-ci.yml. The protected flag makes a variable available only to pipelines of protected branches and tags. Masked hides the value in the log as [MASKED], and masked and hidden also keeps it out of the settings after it is saved.

  • Since GitLab 18.3 a new project variable is masked by default. A maskable value is one line without spaces, 8 characters or more.
  • Masking is not a guarantee of protection: a command that prints the value in a modified form will show it. The File type and an external secrets manager keep env and printenv from printing the secret.
  • Pipelines from forks do not get the variables of the parent project by default.
  • A variable with an environment scope reaches only the jobs of that environment.

OIDC in GitLab is enabled with the id_tokens key: GitLab issues a JWT for the job, and aud restricts which service will accept it. By default sub has the form project_path:group/project:ref_type:branch:ref:main.

yaml.gitlab-ci.yml
deploy:  id_tokens:    CLOUD_ID_TOKEN:      aud: https://cloud.example.com  script:    - ./cloud-login.sh "$CLOUD_ID_TOKEN"

Section sources

the section is written from these pages

Environments and deployment

An environment is a named deployment target, such as staging or production, with its own secrets, variables and protection rules. A job that references an environment waits until every rule is satisfied — an approval, a timer, an allowed branch — and only then reaches a runner.

yaml.github/workflows/deploy.yml
on:  push:    branches: [main]jobs:  staging:    runs-on: ubuntu-latest    environment:      name: staging      url: https://staging.example.com    steps:      - uses: actions/checkout@v7      - run: ./deploy.sh staging  production:    needs: staging    runs-on: ubuntu-latest    environment:      name: production      url: https://example.com    concurrency:      group: production      cancel-in-progress: false    steps:      - uses: actions/checkout@v7      - run: ./deploy.sh production        env:          DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}

Each run of such a job creates a deployment object with the environment’s name and its url; deployment: false in environment gives the job the environment’s secrets without a deployment object. If the environment does not exist yet, the first run creates it with no protection rules or secrets. So configure the environment in advance in “Settings → Environments”; the repository owner or an administrator can do this.

Protection rules

RuleWhat it doesWhere available
Required reviewersup to 6 people or teams; a single approval is enough; you can forbid approving your own runon Free, Pro and Team — public repositories only
Wait timerdelays the job by 1–43,200 minutes, up to 30 daysthe same
Branches and tags for deploymentno restrictions, protected branches only, or selected name patternsprivate repositories — with Pro and Team
Bypass preventionadministrators can no longer deploy around the rules; bypass is allowed by defaulton Free, Pro and Team — public repositories only
Custom rulesapproval by an external service through a GitHub App; up to 6 rules on an environment at a timepublic preview; on Free, Pro and Team — public repositories only

Environment secrets and variables are available only to that environment’s jobs, and with required reviewers — only after approval. This way the production token never ends up with just any job in the repository. On self-hosted runners the environment does not isolate the job: protect such secrets the same way as repository secrets.

One deployment at a time

concurrency on a deployment job prevents two runs from deploying to the same environment at the same time: while one deployment is running, the next one waits. For a deployment, do not enable cancel-in-progress, so that it is not interrupted halfway. By default only one run may wait: an earlier waiting run is cancelled. queue: max builds a queue of up to 100 runs, and they run one at a time in the order in which they queued.

yamljob snippet
concurrency:  group: deploy-production  queue: max

Deployment strategies — rolling, blue-green and canary — are carried out on the target system itself. For clusters they are described in the Kubernetes reference, the section “Deploying updates and rollback”.

GitLab CI

In GitLab the environment key on a deployment job sets the environment; if an environment with that name does not exist yet, GitLab will create it. A job with when: manual waits for a manual start, so production is deployed with the press of a button, while resource_group keeps two deployments in one group from running at the same time.

yaml.gitlab-ci.yml
deploy-staging:  stage: deploy  script: ./deploy.sh staging  environment:    name: staging    url: https://staging.example.com  rules:    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH deploy-production:  stage: deploy  needs: [deploy-staging]  script: ./deploy.sh production  environment:    name: production    url: https://example.com  resource_group: production  rules:    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH      when: manual
  • With when: manual inside rules, allow_failure defaults to false: the pipeline waits for a manual start. With when: manual outside rules it is true, and the pipeline can finish without waiting for the deployment.
  • Protected environments (Premium, Ultimate) restrict who can deploy (the “Allowed to deploy” list) and require approval (the “Approvers” list). They are configured in “Settings → CI/CD → Protected environments” with the Maintainer role.
  • GitLab guesses the deployment tier from the name: production, staging, testing, development or other; deployment_tier sets it explicitly.

Section sources

the section is written from these pages

Pipeline security

The main threats to a pipeline are foreign code with access to secrets (a pull request from a fork, a compromised third-party action) and untrusted input substituted straight into commands. The defence is a minimally privileged token, pinned dependency versions, and a ban on running unreviewed code where secrets are present.

Don’t substitute input into run

The PR title, the branch name, the issue body and other github.event fields are set by the person who triggers the event. GitHub substitutes the ${{ … }} expression in run into the script text before it runs, and a title such as a"; ls $GITHUB_WORKSPACE" is executed as a command. Pass such values through an intermediate environment variable: the value then stays a string in memory and never becomes part of the script.

yamldon’t do this
- run: echo "Checking ${{ github.event.pull_request.title }}"
yamlthe right way
- env:    TITLE: ${{ github.event.pull_request.title }}  run: echo "Checking $TITLE"

Least privilege for GITHUB_TOKEN

Least privilege for GITHUB_TOKEN

Pin third-party actions

A maintainer can move the @v7 tag to another commit, and if the action’s repository is compromised, so can an attacker. The most reliable option is a workflow dependency lockfile: it records the exact commit of every action, including nested ones. If a lockfile is not an option, pin the action to the full commit SHA and verify that the SHA comes from the action’s own repository, not a fork.

yamla job step
# full commit SHA, version in a comment for Dependabot- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

Dependabot updates SHA-pinned actions too, and updates the version comment on the same line together with the SHA. Vulnerable-action alerts are sent only for version references, not SHA pins. Read a third-party action’s code before adopting it: where it sends secrets and what it writes to the log.

pull_request_target and code from forks

To test PRs from forks, use pull_request: its token is read-only and no secrets other than GITHUB_TOKEN are passed. Move the privileged step after validation into a separate workflow on workflow_run and treat the first workflow’s artifacts as untrusted.

Your own runners

Your own runner does not guarantee a clean machine for each job: untrusted code can leave a backdoor on it and read the secrets of later jobs. That is why self-hosted runners are almost never attached to public repositories; for private ones they are split into groups, and the machine keeps a minimum of credentials and network access. Ephemeral JIT runners (just-in-time) run a single job and are then removed.

Protected branches and checks

A branch protection rule with required status checks will not merge a PR until the checks report successful, skipped or neutral. Keep job names unique across all workflows: identical names confuse required status checks. Add the .github/workflows/ directory to CODEOWNERS so that a designated reviewer approves pipeline changes.

GitLab CI

  • Protected variables are available only to pipelines of protected branches and tags, and protected runners run only their jobs. To keep a job meant for a protected runner from landing on a regular one, give it that runner’s labels in tags.
  • Grant the right to merge into a protected branch only to those who may see the deployment secrets.
  • Store the most sensitive secrets in an external secret manager — HashiCorp Vault, Azure Key Vault, Google Cloud Secret Manager. Mask, hide and, where possible, protect secret variables.
  • Specify images by digest — image: python@sha256:… instead of python:3.15 — and where possible do not build the image name from variables: they can be overridden and the image swapped.
  • Install dependencies strictly from the lockfile: npm ci instead of npm install, pip install -r requirements.txt --require-hashes.
  • Pin include from other projects by commit SHA or protected tag, and download the remote file and keep it in the repository.
  • Pass pipeline parameters through inputs rather than pipeline variables: inputs are type-checked when the pipeline is created.

Section sources

the section is written from these pages

Common errors and diagnostics

First, find out whether a workflow run was created at all. If not — the event, the filters or the file path are to blame; if a job failed — read the log of its step. When there is little in the log, re-run the job with debug logging.

  1. Is there a run on the “Actions” tab (in GitLab — “Build → Pipelines”)? If not — check on, the filters and the file path.
  2. Is the job skipped or waiting? Check if, needs and the runs-on label.
  3. A job failed — open the log of the step with the error; the archive of all logs is downloaded from the job menu.
  4. Too few details — re-run the job with debug logging.
  5. Cannot reproduce it — run the job’s commands yourself in the same image.

The workflow does not run

Cause: the file is not in .github/workflows/, or its extension is neither .yml nor .yaml; the event or the branches and paths filters did not match; the workflow is disabled. The schedule and issues events run only the version of the file from the default branch, and the workflow_dispatch button appears only when the file is in that branch. A pull request with a merge conflict and a commit with [skip ci] will not get a run.

bashchecking
gh workflow list --allgh run list --workflow ci.yml --limit 5
bashfix: enable the workflow
gh workflow enable ci.yml

The job is skipped or runs unexpectedly

Cause: the if condition evaluated differently from what you expected, or a job in needs failed. The values substituted into the condition are visible in the job’s system log.

  1. Download the log archive from the job menu and open the JOB-NAME/system.txt file in it.
  2. Look for the Evaluating, Expanded and Result lines: in Expanded the condition is shown with the substituted values.
  3. If if starts with !, wrap the condition in ${{ }}, otherwise YAML reads it incorrectly.

The job is stuck in the queue

Cause: there is no idle runner with all the labels from runs-on. For your own runner — a typo in the label or the runner application is not running; for a hosted one — a label of an image that does not exist or has already been retired.

  • Compare runs-on with the runner labels in “Settings → Actions → Runners”.
  • Give your own runners unique labels: a label that matches the label of a hosted image makes runner selection unpredictable.

A step fails with a permission denied error

Cause: GITHUB_TOKEN lacks the required permission. As soon as at least one permission is listed in permissions, all the unlisted ones become none, and in a pull request from a fork the token can only read. Add the required permission to the job.

yamlfix
permissions:  contents: read  pull-requests: write

The secret is empty

Cause: the secret does not exist or is named differently — a missing secret yields an empty string, not an error. Also, workflows triggered from a fork or by Dependabot get no secrets, and a job without environment will not receive an environment secret.

yamlchecking
jobs:  deploy:    runs-on: ubuntu-latest    env:      DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}    steps:      - if: env.DEPLOY_TOKEN == ''        run: |          echo "DEPLOY_TOKEN is not set"          exit 1

The schedule runs late or has stopped

Cause: at the start of every hour the load is higher, so schedule runs are delayed, and under heavy load some are dropped. If the schedule has stopped firing while a manual run works, the account that scheduled runs go under (the actor) may have been blocked, deleted or disabled.

  • Move the time away from the start of the hour: 17 3 * * * instead of 0 3 * * *.
  • To restore the schedule, commit the cron change as a user with write access.

GitHub Actions debug logging

Secret or variableWhat it enables
ACTIONS_STEP_DEBUG = trueverbose step logging
ACTIONS_RUNNER_DEBUG = truerunner logs in the runner-diagnostic-logs folder of the archive

Set them as a repository secret or variable; if both are set, the secret wins. Anyone who can run workflows can enable debugging for a single re-run, and the runner.debug context lets your steps know that debugging is on.

GitLab CI: yaml invalid

Cause: a syntax or indentation error, and a pipeline marked this way does not run. Check the file in the pipeline editor or in CI Lint — it can also simulate creating a pipeline.

config contains unknown keys

Cause: a typo in a key — imag instead of image — or an incorrect indent that put the key at the wrong level.

Job may allow multiple pipelines to run for a single action

Cause: a rule with when but no if lets through both the branch pipeline and the merge request pipeline, so a push to a branch with an open merge request creates both. Set the pipeline types in workflow:rules.

Failed to pull image

A common cause: the image lives in the registry of another, private project. Such a project only admits the job token from the projects on its job token allowlist, and your project is not on it. Add your project to the list.

yamlfragment of .gitlab-ci.yml
deploy:  variables:    CI_DEBUG_TRACE: "true"

Section sources

the section is written from these pages

Versions and what’s new

This reference describes GitLab 19.5; the latest release is 19.5.3, dated 29 October 2026. Only the current minor version of GitLab receives bug fixes; security fixes also reach the two preceding versions. GitHub Actions is a service without version numbers: its changes are published in the GitHub Changelog.

GitLab branchStatusLatest releaseSupport
19.5current: bugs and security19.5.3, 29 October 2026bugs — until 19.6 is released, security — until 19.8 is released
19.4security only19.4.5, 29 October 2026until 19.7 is released
19.3security only19.3.7, 29 October 2026until 19.6 is released
19.2no longer supported19.2.10, 29 October 2026 — an out-of-policy fix—

Minor versions of GitLab come out every month on the third Thursday, patches twice a month and the major version once a year, in May. GitLab Runner 19.5 was released together with GitLab 19.5. Upgrading GitLab does not affect your runners — upgrade them separately.

WhatVersionWhere to check
GitHub runner application actions/runner2.338.2, 26 October 2026Releases · actions/runner
The GitHub Actions used in the examplescheckout@v7, setup-python@v7, upload-artifact@v7, download-artifact@v8, cache@v6Releases of each Action on GitHub
The Docker Actions used in the exampleslogin-action@v4, metadata-action@v6, setup-buildx-action@v4, build-push-action@v7Releases of each Action on GitHub

What’s new in GitLab 19.5

  • Secrets, variables and OIDC: GitLab Secrets Manager has become generally available (Premium and Ultimate, a separate paid add-on). This is a secret store on OpenBao with group and project permissions. A secret is issued to a job by environment, branch and its protection status, and every access is recorded in the audit log.
  • Jobs, steps and matrices: a child pipeline job can depend on a parent job as an optional one — if the parent has not run, the child proceeds without it.
  • Runners: the variables CI_JOB_TAGS and CI_RUNNER_TAGS now encode each tag in JSON.

What’s new in GitHub Actions

  • Runners: on 17 September 2026 the Ubuntu 26.04 image became generally available. The ubuntu-latest label is moving to it gradually, from 19 October to 19 November 2026; if it is too early to switch, pin ubuntu-24.04.
  • Runners: runner application 2.338 uses Node 24 instead of Node 20 for its own operations, such as hashFiles().
  • Artifacts and cache: on 10 September 2026 the cache-mode key appeared, which restricts workflow and job access to the cache.
  • Pipeline security: on 17 September 2026 workflow execution protections became generally available. In public repositories without their own policy, the default rule forbids pull_request_target; it will start being enforced on 2 December 2026.
  • Pipeline security: on 28 October 2026 the workflow dependency lockfile became generally available.

Deprecated and removed

  • Node 20 on GitHub-hosted runners was removed on 23 September 2026: JavaScript Actions now run on Node 24, so update your Actions to Node 24 versions. Self-hosted runners on macOS 13.4 and older and on ARM32 are no longer supported.
  • The macOS 14 runner image (macos-14) is being retired on 2 November 2026 — move to macos-15 or macos-latest.
  • GitLab 19.5: the cancel_merge_when_pipeline_succeeds API endpoint is deprecated, use cancel_auto_merge instead.

Security updates

IdentifierWhat is affectedFixed in
CVE-2026-111943trust in eight compromised eMudhra intermediate certificates; GitLab Runner needs a separate upgrade to 19.5.119.5.3, 19.4.5, 19.3.7
CVE-2026-110264server-side code execution without signing in, via a specially crafted regular expression, CVSS 10.019.5.1, 19.4.3, 19.3.6
CVE-2026-97229server-side code execution via a regular expression in the CI/CD configuration, CVSS 10.019.4.2, 19.3.5, 19.2.8
CVE-2026-16301a developer could run pipelines on protected branches by creating a child pipeline, CVSS 8.519.4.2, 19.3.5, 19.2.8
CVE-2026-93577server-side code execution via a regular expression in the CI/CD configuration, CVSS 9.919.4.1, 19.3.3, 19.2.7
CVE-2026-89078server-side code execution via parsing a regular expression in the CI/CD configuration, CVSS 9.919.4.1, 19.3.3, 19.2.7
CVE-2026-79708a developer obtained protected CI/CD variables through a policy test pipeline (EE), CVSS 8.519.3.2, 19.2.6, 19.1.8
CVE-2026-13210access to CI/CD variables of someone else’s environment scope, CVSS 7.719.3.2, 19.2.6, 19.1.8

Section sources

the section is written from these pages

End of the reference

What changed

revision history · 4 entries

Every edit is saved as a revision: a snapshot of the reference, the reason and a summary of changes. The published version changes only after the same checks as at creation.

  1. Manual edit

    reason: manual edit
  2. Manual edit

    reason: manual edit
  3. Manual edit

    reason: manual edit
  4. Reference updated

Weekly check

How the reference is checked

Once a week — and right after news of a release or a vulnerability — the reference is checked in three steps.

  1. 1. Freshness

    Sections are compared with the release notes and changelogs from the official sources and with the topic’s news.

  2. 2. Errors

    Every section is read again: wrong facts, outdated APIs and flags, broken examples.

  3. 3. Links — by an HTTP request

    Every source link must respond. A broken link is a reason to recheck the section.

No findings — only the date changes. Findings — only the affected sections are rewritten, and they appear in “What changed”. A new version replaces the published one only after passing the same checks as at creation.

Statuses

Verified
no findings
Updated
sections rewritten, edits are listed
Rechecking
while the check runs, the previous version stays open
Needs review
disputed points: the verified version is shown, editors review

Last check

18 Nov · Check · updated · no findings

Found an error in the reference?

On the topic

tracks, news and other references
The whole “CI/CD” topic
13 sections
Another reference · DevOps & cloud

Docker

Verified 31 Oct
All references · 61