GitLab CI/CD for GitHub Actions users

Interview prep for Sam Myers. Checked against docs.gitlab.com on Oct 22, 2026.

Read this first

This guide is for someone who already runs GitHub Actions in production. It skips anything that works the same way in both systems and spends its space on the places where GitLab CI/CD thinks differently.

The content was checked against docs.gitlab.com on Oct 22, 2026. The docs describe GitLab 19.x at that date, so a few features below carry a version note. Each section ends with a Sources list. Anything I could not confirm in GitLab's docs has an Unverified tag.

The biggest shift is this. A GitHub repo can hold many workflow files, each with its own on: trigger. A GitLab project has one pipeline definition, .gitlab-ci.yml, plus whatever it includes. Every event creates a pipeline from that one file, and rules decide which jobs survive into it. You filter jobs out of one pipeline instead of picking which workflow runs.

1. Mental model map

GitHub ActionsGitLab CI/CDWhat changes
Workflow files in .github/workflows/*.ymlOne .gitlab-ci.yml at the repo root (the path is configurable), plus files pulled in with include.Several workflows become one pipeline. Split it back up with include:local or child pipelines.
on: events$CI_PIPELINE_SOURCE values tested in workflow:rules and job rules.There is no trigger block. The event happens, GitLab builds a pipeline, then rules filter it.
jobs:Top-level keys that aren't reserved keywords are jobs.Any key starting with . is a hidden job, which is the usual home for templates.
Job ordering through needs:stages: sets the default order. needs: overrides it and builds a DAG.Without needs, a job waits for every job in all earlier stages. With needs: [], it starts right away. A job can list at most 50 needs.
steps: with run: and uses:script: (plus before_script and after_script), which is a list of shell lines.There are no steps or step-level uses. after_script runs in a new shell, so state from script doesn't carry over. GitLab also has a newer run keyword for CI steps, which this guide does not cover.
runs-on: labelstags: match runner tags. image: picks the container.Runners are scoped to an instance, a group, or a project. Each runner has an executor (shell, docker, docker-autoscaler, kubernetes, and others).
Marketplace actionsinclude (local, project, remote, template, component), extends, YAML anchors, !reference, and CI/CD components in the CI/CD Catalog.A component is a YAML fragment that gets merged into your config, not a packaged program like a JS or Docker action.
strategy.matrixparallel:matrix, an array of hashes of variables.There is a 200-permutation cap. Values arrive as CI/CD variables, not as a matrix context. Plain parallel: N sets CI_NODE_INDEX and CI_NODE_TOTAL for test splitting.
secrets.* and vars.*CI/CD variables (project, group, or instance) that can be masked, masked and hidden, protected, or file type, and scoped to an environment.Every variable shows up as an env var. Nothing marks it as a secret except its masking. File-type variables put the value in a temp file and the env var holds the path.
environment: plus environment protection rulesenvironment: (name, url, deployment_tier, on_stop, auto_stop_in) plus protected environments and deployment approvals. PremiumEnvironments get created the first time a job deploys to them. Dynamic names such as review/$CI_COMMIT_REF_SLUG give you review apps.
upload-artifact / download-artifactartifacts: on the producer. Consumers download automatically.By default a job downloads artifacts from all jobs in earlier stages. dependencies and needs:artifacts narrow this down.
actions/cachecache: with key, paths, policy, and fallback_keys.The cache lives on the runner host unless distributed (S3) cache is configured. Protected and unprotected refs get separate caches.
Reusable workflows (workflow_call)Child pipelines (trigger:include) in the same project, multi-project pipelines (trigger:project), or plain include for inline reuse.A trigger job reports success as soon as the downstream pipeline is created, unless you set strategy: mirror.
workflow_dispatch inputsPipeline inputs declared in spec:inputs (17.11+), entered when you run a pipeline by hand. Job inputs arrived in 18.10.Inputs are typed (string, number, boolean, array) and get interpolated with $[[ inputs.x ]] when the pipeline is created.
concurrency:resource_group serializes jobs. interruptible plus workflow:auto_cancel cancels redundant pipelines.GitLab splits the two jobs that concurrency does in one keyword.
permissions: id-token: write and OIDCid_tokens: on the job, each token with its own aud.Name the token and it appears as an env var. The default sub is project_path:{group}/{project}:ref_type:{type}:ref:{branch}.
GITHUB_TOKENCI_JOB_TOKENAccess to other projects goes through each target project's job token allowlist, not through a permissions block.

Events vs pipeline sources

GitHub event$CI_PIPELINE_SOURCE
push (branch)push, with $CI_COMMIT_BRANCH set
push (tag)push, with $CI_COMMIT_TAG set
pull_requestmerge_request_event (requires rules that match it, see Pipeline control)
scheduleschedule (cron schedules are set in the UI or API, not in YAML)
workflow_dispatchweb (Run pipeline button) or api
repository_dispatchtrigger (trigger token) or api
workflow_callparent_pipeline (inside a child pipeline)
workflow_runpipeline (multi-project downstream)

Unverified The GitHub column comes from my own working knowledge of GitHub Actions. I did not re-check it against GitHub's docs for this guide. The event-to-source pairs are my mapping. GitLab documents each source value, not the GitHub equivalents.

Sources

2. Pipeline control

rules

GitLab evaluates rules top to bottom and stops at the first match. A match adds the job, or removes it with when: never. If nothing matches, the job is left out. A rule can combine if, changes, and exists, and all of them must be true. A rule can also set when, allow_failure, variables, needs, and interruptible.

deploy:
  script: ./deploy.sh
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      when: manual
      allow_failure: true          # a manual job that doesn't block the pipeline
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      changes:
        - infra/**/*
    - when: never                  # explicit; the default is the same

Rules run before any job starts, so dotenv variables that a job writes can't steer rules. Expressions support ==, !=, =~, !~ (RE2 regex), &&, ||, and parentheses. GitLab 18.11 added ! for negation.

workflow:rules

This decides whether a pipeline gets created at all. GitLab evaluates it before any job rules. The pattern you will see everywhere runs MR pipelines when an MR is open and branch pipelines otherwise:

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    - if: $CI_COMMIT_BRANCH

workflow also holds name (a dynamic pipeline title), rules:variables, and auto_cancel.

only / except

Deprecated. Use rules. Don't mix the two in one pipeline. A job with neither keyword behaves like except: merge_requests, which is one source of the duplicate-pipeline problem below.

Merge request pipelines vs branch pipelines

  • A branch pipeline runs on every push. It has $CI_COMMIT_BRANCH but no MR variables.
  • A merge request pipeline runs only if some job or workflow:rules in .gitlab-ci.yml itself matches merge_request_event. Rules inside an included component don't count. It tests the source branch alone and gets CI_MERGE_REQUEST_* variables.
  • A merged results pipeline Premium tests the source branch merged into the target, which is close to what GitHub does with the PR merge ref. Turn it on in project settings.
  • For an MR from a fork, the pipeline runs in the fork with the fork's variables and runners. Parent project secrets are not exposed by default.

Duplicate pipelines

This is the classic Actions-user mistake. One push to a branch with an open MR fires both a push event and an MR event. If any job's rules accept both, for example a final - when: always, you get two pipelines. Fix it with the workflow:rules block above (the $CI_OPEN_MERGE_REQUESTS check), or write job rules that match only one source.

Merge trains Premium

This is a queue of MRs. Each one gets a merged results pipeline built on the target branch plus every MR ahead of it, and the pipelines run in parallel (20 per train by default, configurable since 19.0). If MR B fails, GitLab drops B, cancels the pipelines behind it, and rebuilds them without B. You can't retry a failed train pipeline. Re-add the MR, or use retry on flaky jobs. Since 19.3, enforcement can block the "merge immediately" bypass. GitHub's merge queue is the closest match.

interruptible and auto-cancel

Auto-cancel redundant pipelines is a project setting. workflow:auto_cancel:on_new_commit controls it with three modes:

  • conservative (default) cancels the old pipeline only if no job with interruptible: false has started.
  • interruptible cancels only the jobs marked interruptible: true.
  • none cancels nothing.

Mark builds and tests interruptible. Leave deploys alone. Under conservative, once one non-interruptible job starts, nothing in that pipeline gets auto-canceled.

resource_group

This is a mutex across pipelines for jobs with the same group name, so it plays the role of Actions concurrency.group without cancel-in-progress. The default process mode is unordered. You can change it through the API to oldest_first, newest_first, or newest_ready_first. The two newest modes skip outdated deploys, but each job must be idempotent.

deploy-prod:
  stage: deploy
  script: ./deploy.sh
  resource_group: production
  interruptible: false
Sources

3. Includes and reuse

include types

TypePulls fromNotes
include:localA file in the same repo and refThe cheapest way to split a large config.
include:project + file + refAnother project on the same instance, including private onesref defaults to HEAD. Pin a tag or SHA.
include:remoteA public HTTPS URLNo authentication. You can pin the content with include:integrity.
include:templateGitLab's bundled templates, such as Jobs/SAST.gitlab-ci.ymlThese ship with the GitLab version.
include:component$CI_SERVER_FQDN/group/project/name@versionVersioned, takes inputs, can be listed in the Catalog.

GitLab resolves includes first and then merges your file on top, wherever the include key sits. Your .gitlab-ci.yml wins on conflicts. A local job with the same name as an included job deep-merges into it, which is how you override included jobs. The limits are 150 includes per pipeline (nested ones count) and 30 seconds to resolve them all. A retried job keeps the include content fetched when the pipeline was created.

extends, anchors, and !reference

  • extends reverse-deep-merges hashes from one or more parent jobs, usually hidden ones. It does not merge arrays. A child's script replaces the parent's. It works across included files and allows up to 11 levels.
  • YAML anchors (&x, *x, <<: *x) are plain YAML and don't work across included files.
  • !reference [.job, key, subkey] pulls one value from another job, even one in an included file. Use it to splice script lines or rules lists together, which extends can't do. You can nest it up to 10 levels in scripts.
.setup:
  script:
    - npm ci
.default_rules:
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
      when: never
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

test:
  script:
    - !reference [.setup, script]
    - npm test
  rules:
    - !reference [.default_rules, rules]
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

CI/CD components and spec:inputs (GA in 17.0)

A component project keeps templates/<name>.yml or templates/<name>/template.yml, a README, and up to 100 components that share one version. Each file starts with a spec header, then ---, then normal config. Inputs get interpolated with $[[ inputs.name ]] when the pipeline is created, before merging, so an input can even set a job name.

templates/deploy.yml in the component project

spec:
  inputs:
    stage:
      default: deploy
    env:
      options: [staging, production]
    replicas:
      type: number
      default: 2
---
"deploy-$[[ inputs.env ]]":
  stage: $[[ inputs.stage ]]
  script:
    - ./deploy --env $[[ inputs.env ]] --replicas $[[ inputs.replicas ]]

Consumer .gitlab-ci.yml

include:
  - component: $CI_SERVER_FQDN/platform/ci/deploy@1.4.2
    inputs:
      env: production
      replicas: 4
  • Version resolution, highest priority first: commit SHA, tag, branch. ~latest and partial semver such as 1 or 1.2 work only for releases published to the Catalog. Pin a SHA or a full tag for anything you don't own.
  • Publishing requires turning on the Catalog toggle, then cutting a semver tag whose pipeline creates the release with the release keyword. The Releases API won't publish it.
  • Components merge into your config. Matching job names merge, and global keywords such as default in a component affect every job. Good components avoid globals and let you set job names through inputs.
  • A component can't use spec:include. Since 18.7, spec:component exposes the component's own name, version, and SHA through $[[ component.version ]].
  • To use GitLab.com components on Self-Managed, mirror the project and publish a release there.
Sources

4. Runners in depth

Scopes and selection

Runners come in three scopes. Instance runners serve everyone, and GitLab.com's hosted runners are instance runners. Group runners serve every project in a group and its subgroups. Project runners serve the projects they are assigned to. A job runs on a runner whose tags cover all of the job's tags. Untagged jobs only go to runners set to run untagged jobs. A protected runner only takes jobs from protected branches and tags.

Registration with runner authentication tokens

The old flow took a project or group registration token and passed tags and options as register flags. That flow is deprecated. Registration tokens can be turned off since 17.0, and their removal is scheduled for 20.0. The new flow:

  1. Create the runner in the UI (Settings > CI/CD > Runners) or with POST /user/runners. Tags, protected, run-untagged, maximum timeout, and paused are set here, on the server side.
  2. You get a glrt- runner authentication token.
  3. Run gitlab-runner register --token glrt-... on each host. Every host that reuses the token shows up as a separate runner manager, told apart by its system ID.
sudo gitlab-runner register \
  --non-interactive \
  --url "https://gitlab.com/" \
  --token "$RUNNER_TOKEN" \
  --executor "docker" \
  --docker-image alpine:latest \
  --description "docker-runner"

If you pass a glrt- token through the old --registration-token flag, GitLab ignores --tag-list, --locked, --access-level, and similar flags. Known issue: with automatic token rotation and one token shared by several managers, only the first manager receives the new token.

Autoscaling with docker-autoscaler and fleeting

The Docker Autoscaler executor went GA in Runner 17.1. It wraps the Docker executor and asks a fleeting plugin (aws, googlecloud, azure) to grow and shrink an instance group. It replaces Docker Machine, which was deprecated in 17.5 and is scheduled for removal in 20.0 (May 2027). Install the plugin with gitlab-runner fleeting install.

concurrent = 10

[[runners]]
  name = "docker autoscaler"
  url = "https://gitlab.com"
  token = "<glrt-token>"
  executor = "docker-autoscaler"
  [runners.docker]
    image = "busybox:latest"
  [runners.autoscaler]
    plugin = "aws"
    capacity_per_instance = 1   # jobs per VM at once
    max_use_count = 1           # 1 = fresh VM per job
    max_instances = 10
    [runners.autoscaler.plugin_config]
      name = "my-docker-asg"    # dedicated ASG for this runner
    [runners.autoscaler.connector_config]
      username = "ec2-user"
      use_external_addr = true
    [[runners.autoscaler.policy]]
      idle_count = 5
      idle_time = "20m0s"

AWS details from the docs:

  • The AMI needs Docker but not the runner.
  • The runner owns all scaling. Set the ASG scaling policy to none, turn on scale-in protection, and turn off AZRebalance. If AZRebalance stays on, jobs fail with "unable to acquire instance".
  • Give each [[runners]] entry its own ASG. Never share one between managers.
  • Set concurrent to max_instances × capacity_per_instance.

Kubernetes executor

This executor runs one pod per job. The pod has a build container, a helper container that handles clone, cache, and artifacts, and one container per service. Services share the pod's network namespace, so two services can't use the same port. Admins set limits in [runners.kubernetes] (namespace, node_selector, cpu and memory requests and limits, privileged). Jobs can raise their own resources with variables such as KUBERNETES_CPU_REQUEST, but only up to the *_overwrite_max_allowed caps. Service account and namespace overrides are allowed only when an admin sets an allow regex. Most teams install it with the GitLab Runner Helm chart.

GitLab.com hosted runners

  • Linux x86-64 runs on GCP in us-east1 and us-east5. Linux Arm64 runs in us-central1. Every job gets a fresh, isolated VM running the docker+machine executor.
  • Untagged jobs land on saas-linux-small-amd64 (2 vCPU, 8 GB). Ask for bigger machines with tags such as saas-linux-medium-amd64. Large and above, up to 2xlarge with 32 vCPU, need Premium or Ultimate.
  • Windows and macOS are in beta and accept only the supported images. GPU runners also exist.
  • Jobs use compute minutes, scaled by a cost factor that depends on machine size.

Runner knobs worth knowing

  • concurrent is the global job cap. limit caps one [[runners]] entry. request_concurrency (default 1) caps parallel requests for new jobs. check_interval defaults to 3 seconds.
  • listen_address exposes Prometheus metrics at /metrics.
  • The cache stays local to the runner host unless you set up a distributed cache (S3 or GCS) in [runners.cache]. Autoscaled fleets need one.
Sources

5. Security and deployments

Environments

Setting environment:name on a job turns that job into a deployment and creates the environment if it doesn't exist. Other useful keys are url, on_stop with action: stop for teardown jobs, auto_stop_in, and deployment_tier. The tier must be one of production, staging, testing, development, or other. Variables are allowed there since 18.5. Changing the tier in YAML later doesn't update an existing environment. Use the API for that.

Protected environments and approvals Premium

  • A protected environment restricts who may deploy to it (roles, users, or groups). It is the counterpart of GitHub's required reviewers plus deployment branch rules, split into two settings. At the group level you protect by deployment tier, so one rule covers production in every project of the group.
  • Deployment approvals hold the job until enough approvers sign off. By default, the person who triggered the pipeline can't approve their own deploy. After approval, someone runs the job manually. Protecting an environment needs at least the Maintainer role.
  • Pair this with protected branches and protected variables. A protected variable reaches only jobs on protected refs. Scope production credentials to the production environment so a feature branch never sees them.

OIDC to AWS with id_tokens

On the AWS side, create an IAM OIDC provider for https://gitlab.com (or your instance URL, which must be publicly reachable). Then write a role trust policy for sts:AssumeRoleWithWebIdentity that checks the sub claim. On GitLab.com, AWS also accepts namespace_id, project_id, ref_protected, pipeline_source, and a few other claims as condition keys. Pin project_id, because it survives renames and transfers. Self-Managed and Dedicated support only sub and aud.

{
  "Effect": "Allow",
  "Principal": { "Federated": "arn:aws:iam::AWS_ACCOUNT:oidc-provider/gitlab.com" },
  "Action": "sts:AssumeRoleWithWebIdentity",
  "Condition": {
    "StringEquals": {
      "gitlab.com:sub": "project_path:mygroup/myproject:ref_type:branch:ref:main",
      "gitlab.com:project_id": "67890"
    }
  }
}

Unlike aws-actions/configure-aws-credentials, GitLab ships no built-in action for this. You call STS yourself, as in the YAML example in section 6. CI_JOB_JWT_V2 was removed in 17.0. If AWS says "Not authorized to perform sts:AssumeRoleWithWebIdentity", check the ref conditions, and check for a wildcard used with StringEquals where StringLike is needed.

External secrets Premium

The secrets: keyword fetches values at job start. GitLab supports HashiCorp Vault, AWS Secrets Manager (GA in 18.3), Google Cloud Secret Manager, and Azure Key Vault. They arrive as file-type variables unless you set file: false. For AWS Secrets Manager, the runner looks for an ID token named AWS_ID_TOKEN plus AWS_REGION and AWS_ROLE_ARN variables.

migrate:
  variables:
    AWS_REGION: us-east-1
    AWS_ROLE_ARN: arn:aws:iam::123456789012:role/gitlab-secrets-role
  id_tokens:
    AWS_ID_TOKEN:
      aud: sts.amazonaws.com
  secrets:
    DB_PASSWORD:
      aws_secrets_manager:
        secret_id: app-secrets/database
        field: password
      file: false
  script:
    - ./migrate.sh

Vault uses the same keyword. The short form vault: production/db/password@ops reads field password from ops/data/production/db on a KV v2 engine. Vault also needs its server URL and an ID token configured.

The runner manager resolves secrets, not the job pod. On EKS with IAM-role auth, the role must be on the manager, or the job fails with "no EC2 IMDS role found". Masking isn't a security boundary, because a script that changes the value slightly will print it. The docs recommend external secrets plus file-type variables. A variable saved as "Masked and hidden" can't be revealed in the UI again.

Security scanning templates

GitHub has no built-in equivalent at this level. Each scanner is one include, and the results feed MR widgets and the vulnerability report on Ultimate.

include:
  - template: Jobs/SAST.gitlab-ci.yml                   # Free; MR/report UI is Ultimate
  - template: Jobs/Secret-Detection.gitlab-ci.yml       # Free; MR/report UI is Ultimate
  - template: Jobs/Dependency-Scanning.v2.gitlab-ci.yml # Ultimate (SBOM-based)
  • You tune scanners with CI/CD variables, and for the v2 dependency scanning template, with inputs.
  • Gemnasium-based dependency scanning has been deprecated since 17.9, with removal proposed for 20.0. SBOM-based scanning is the recommended path.
  • Security teams can force scans into pipelines they don't own with scan execution policies.
Sources

6. Gotchas and a side-by-side translation

  • No checkout step. The runner clones or fetches the repo before every job. New projects default to a shallow clone of depth 20. Set GIT_DEPTH or GIT_STRATEGY to change it.
  • Stages are barriers. Without needs, a job waits for every job in all earlier stages. If a stage fails, later stages don't start, but jobs already running in the current stage keep going. A job with no stage lands in test.
  • Artifacts flow by default. Jobs download every earlier-stage artifact. Use dependencies: [] or needs: [{job: x, artifacts: false}] to skip them. needs on a matrix job pulls artifacts from every matrix instance, and files with the same name overwrite each other.
  • Artifacts from the latest successful pipeline are kept. expire_in doesn't apply to them unless "keep latest artifacts" is turned off.
  • MR pipelines don't happen unless you ask. With no rule matching merge_request_event in .gitlab-ci.yml itself, you only get branch pipelines.
  • A final - when: always rule creates duplicate pipelines. See section 2.
  • extends doesn't concatenate arrays. The child's script or rules replaces the parent's. Use !reference to combine them.
  • Some keywords don't merge with default. This applies to id_tokens, after_script, and some others. When a job sets its own value, GitLab drops the default instead of merging it.
  • Protected means protected refs. Protected variables and protected runners are invisible to MR pipelines from unprotected branches. Your deploy job "can't see the secret" because it ran on a feature branch.
  • Caches split by protection. Protected and unprotected refs use separate cache keys (-protected and -non_protected suffixes). Setting cache:unprotect: true shares them, which is a poisoning risk.
  • Trigger jobs report success early. A trigger job passes once the downstream pipeline is created. Use trigger:strategy: mirror to wait for it. Trigger jobs accept only a small set of keywords and no script.
  • Pipeline variables don't flow downstream. Use trigger:forward to pass them on, or better, trigger:inputs.
  • Variable precedence differs. Manual job, pipeline, project, group, and instance variables all override values in .gitlab-ci.yml. A value set in the UI beats the one in your YAML.
  • after_script runs in a new shell. Exports and cwd from script are gone. It also runs on cancel (17.0+) and on script_failure.
  • needs on a rules-excluded job breaks pipeline creation. Use needs:optional: true.
  • Includes are snapshotted per pipeline. Retrying a job reuses the include content fetched at creation. A new pipeline fetches fresh content.

Side by side: build, test matrix, deploy to AWS with OIDC

.github/workflows/ci.yml

name: ci
on:
  push:
    branches: [main]
  pull_request:

permissions:
  id-token: write
  contents: read

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      - run: npm run build
      - uses: actions/upload-artifact@v4
        with:
          name: dist
          path: dist/

  test:
    needs: build
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node: [20, 22]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node }}
          cache: npm
      - run: npm ci
      - run: npm test

  deploy:
    needs: test
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    environment: production
    concurrency: production
    steps:
      - uses: actions/download-artifact@v4
        with:
          name: dist
          path: dist/
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/deploy
          aws-region: us-east-1
      - run: aws s3 sync dist/ s3://my-bucket --delete

.gitlab-ci.yml

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  auto_cancel:
    on_new_commit: interruptible

stages: [build, test, deploy]

default:
  image: node:22
  interruptible: true

.npm:
  cache:
    key:
      files: [package-lock.json]
    paths: [.npm/]
  before_script:
    - npm ci --cache .npm --prefer-offline

build:
  stage: build
  extends: .npm
  script:
    - npm run build
  artifacts:
    paths: [dist/]
    expire_in: 1 week

test:
  stage: test
  extends: .npm
  image: node:${NODE_VERSION}
  needs:
    - job: build
      artifacts: false
  parallel:
    matrix:
      - NODE_VERSION: ["20", "22"]
  script:
    - npm test

deploy:
  stage: deploy
  image:
    name: amazon/aws-cli:latest
    entrypoint: [""]
  needs: [build, test]
  rules:
    - if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  interruptible: false
  resource_group: production
  environment:
    name: production
    deployment_tier: production
  id_tokens:
    AWS_ID_TOKEN:
      aud: sts.amazonaws.com
  variables:
    AWS_DEFAULT_REGION: us-east-1
    ROLE_ARN: arn:aws:iam::123456789012:role/deploy
  script:
    - >
      aws_sts_output=$(aws sts assume-role-with-web-identity
      --role-arn ${ROLE_ARN}
      --role-session-name "gitlab-${CI_PROJECT_ID}-${CI_PIPELINE_ID}"
      --web-identity-token ${AWS_ID_TOKEN}
      --duration-seconds 3600
      --query 'Credentials.[AccessKeyId,SecretAccessKey,SessionToken]'
      --output text)
    - export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" $aws_sts_output)
    - aws s3 sync dist/ s3://my-bucket --delete

What maps to what in that translation

  • on: push / pull_request plus concurrency.cancel-in-progress become workflow:rules (MR pipelines, no duplicates) plus auto_cancel: interruptible with interruptible: true in default.
  • setup-node with an npm cache becomes image: node:22 plus a cache keyed on package-lock.json. The cache path sits inside the project directory because cache:paths must be relative to $CI_PROJECT_DIR.
  • strategy.matrix becomes parallel:matrix, with the matrix variable used in image. That pattern is in GitLab's job control docs.
  • needs: build without artifacts becomes needs: [{job: build, artifacts: false}]. The deploy job's needs: [build, test] waits for all matrix instances and downloads dist/ from build.
  • if: on deploy becomes rules. The environment becomes environment plus a protected environment configured in settings. Job-level concurrency becomes resource_group.
  • configure-aws-credentials becomes id_tokens plus an explicit assume-role-with-web-identity call. That pattern comes straight from GitLab's AWS OIDC doc. entrypoint: [""] is needed because the aws-cli image's entrypoint is aws.

Unverified Two lines in the translation rely on outside behavior that GitLab's docs don't cover. First, entrypoint: [""] for amazon/aws-cli is common practice based on that image's entrypoint. Second, as a simpler alternative to the export line, the AWS CLI and SDKs read AWS_ROLE_ARN plus AWS_WEB_IDENTITY_TOKEN_FILE, so you can write $AWS_ID_TOKEN to a file and skip the STS call. That is AWS behavior, and I did not verify it against AWS docs here. I checked the YAML by hand against the GitLab keyword reference but did not run it through GitLab's CI Lint.

Sources

7. Interview angles

Likely topics, not known questions I picked these from the role (SRE running CI at scale) and from the material above. Nobody told me these will come up. Each answer is a short starting point to talk from.

A job sits in "pending" forever. What do you check?

Check whether any online runner matches all of the job's tags, and whether untagged jobs are allowed if the job has none. A protected runner won't pick up jobs from an unprotected ref. On the runner side, check that concurrent and limit aren't saturated, and for autoscalers, that max_instances hasn't been reached and the ASG can launch instances. Then read the runner logs and the Prometheus metrics.

Every push creates two pipelines.

Branch and MR pipelines both match. Add workflow:rules with the $CI_OPEN_MERGE_REQUESTS pattern, and remove final when: always rules or mixed only/except.

How would you scale a self-managed runner fleet on AWS?

Use docker-autoscaler with the AWS fleeting plugin and a dedicated ASG per runner config, with AZRebalance off. Size capacity_per_instance and max_use_count to trade isolation for cost (1/1 gives a fresh VM per job). Set idle_count and idle_time for warm capacity, use an S3 distributed cache, scrape /metrics, and reuse one runner auth token across managers.

Pipelines are slow. Where do you start?

Turn stage barriers into a needs DAG. Key caches on lockfiles. Mark jobs interruptible and set auto_cancel. Skip work with rules:changes. Cut artifact downloads with dependencies: []. Split tests with parallel and CI_NODE_INDEX. Check GIT_DEPTH and image pull policy.

A flaky test keeps knocking MRs off the merge train.

You can't retry a failed train pipeline, so use retry with when: limited to infrastructure failure types, then fix or quarantine the test. Watch the train restart cost, because each drop rebuilds every pipeline behind it.

How do you deploy to AWS without long-lived keys?

Use id_tokens with an IAM OIDC provider, and a trust policy that pins sub (ref) and project_id. Add a protected branch, a protected environment with approvals, and resource_group on the deploy job.

A Kubernetes-executor job fails with a system failure before the script runs.

Look at the helper container and pod events (scheduling, image pull, resource quota). Check RBAC for the runner service account and the overwrite caps. If secrets resolution is failing, the IAM role belongs on the runner manager.

A job output leaked a secret even though it was masked.

Masking matches exact strings only. Encoded or transformed values get through. Move the value to an external secrets provider, use file-type variables, and rotate the leaked value. Turn on CI_DEBUG_TRACE only with care, because its output is visible to anyone who can read job logs.

A shared component change broke 200 projects.

Consumers should pin a SHA or full semver, not ~latest or a branch. Test the component in its own pipeline before tagging. Catalog analytics (Premium usage tab) shows who still runs an old version.

Runners went offline right after token rotation.

This is a known issue. With one auth token shared by several runner managers, only the first manager gets the rotated token. Update the others by hand or automate it.

Sources

What is unverified

  • The GitHub Actions side of every comparison comes from working knowledge. I did not re-check it against GitHub's docs for this guide.
  • The event-to-pipeline-source table is my mapping. GitLab documents each source, not the GitHub pairing.
  • In the YAML translation, entrypoint: [""] for the aws-cli image and the AWS_WEB_IDENTITY_TOKEN_FILE alternative depend on AWS and Docker image behavior, not GitLab docs. I checked the YAML by hand and did not run it through CI Lint.
  • Section 7 lists likely topics, not known interview questions.
  • Version numbers reflect docs.gitlab.com on Oct 22, 2026, which describe GitLab 19.x. GitLab ships monthly, so details such as hosted runner machine types and Docker Machine's removal date can change.