Reference

CI/CD workflows

Compare GitHub Actions and GitLab CI syntax for checks, artifacts, permissions and release controls.

Scope and conventions

GitHub Actions (hosted Ubuntu) and GitLab CI. Rows are independent; fragments need the stated placement and prerequisites. npm examples need package-lock.json and a test script. Pins checked 7 November 2026: checkout v7.0.1, setup-node v7.1.0, upload-artifact v7.0.2, download-artifact v8.0.2. Runner, permission and approval requirements are named; review pins for updates.

Data, caches & artifacts

Pass configuration through the right scope

GitHub Actions

env can define workflow/job/step environment values. GITHUB_ENV sets values for subsequent steps in the same job, not the writing step or another job.

Fragment

GitHub Actions YAML fragment; place it at the scope shown. Referenced project commands/files must exist.

.github/workflows/checks.yml
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
jobs:
  inspect:
    runs-on: ubuntu-24.04
    steps:
      - run: printf 'MODE=check\n' >> "$GITHUB_ENV"
      - run: test "$MODE" = check

Publish a small value through an explicit job output

GitHub Actions

A step writes to GITHUB_OUTPUT; a job exposes a named output; a dependent job reads it through needs. Treat outputs as data, not a shell program.

Fragment

GitHub Actions YAML fragment; place it at the scope shown. Referenced project commands/files must exist.

.github/workflows/checks.yml
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
jobs:
  build:
    runs-on: ubuntu-24.04
    outputs:
      revision: ${{ steps.meta.outputs.revision }}
    steps:
      - id: meta
        run: printf 'revision=%s\n' "$GITHUB_SHA" >> "$GITHUB_OUTPUT"
  inspect:
    needs: build
    runs-on: ubuntu-24.04
    steps:
      - env:
          REVISION: ${{ needs.build.outputs.revision }}
        run: test -n "$REVISION"

Use caches for reusable dependencies, not release identity

GitHub Actions

setup-node can cache npm’s download data keyed by the lockfile; it does not cache node_modules for you. A cache hit does not replace npm ci or prove artifact provenance.

Fragment

Steps-list fragment; requires a committed package-lock.json and preceding checkout.

.github/workflows/checks.yml
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
# Steps inside the test job, after checkout:
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
  with:
    node-version: '26'
    cache: npm
- run: npm ci

Retain a named build or report as an artifact

GitHub Actions

Upload selected generated files explicitly; job workspaces are not automatically shared. This example creates a demonstration text artifact, names it with the source revision and fails if the path is missing.

Fragment

Steps-list fragment for a build job. This produces an illustrative file, not an application release; retention/access policy remains a project decision.

.github/workflows/checks.yml
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
# Steps inside a job named build:
- run: |
    mkdir -p dist
    printf 'example artifact\n' > dist/example.txt
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
  with:
    name: example-${{ github.sha }}
    path: dist/example.txt
    if-no-files-found: error
    retention-days: 7

Download the exact upstream artifact, not a convenient rebuild

GitHub Actions

needs establishes scheduling, not file transfer. Explicitly download the selected artifact from the intended run and verify its identity before promotion.

Fragment

Jobs fragment requiring the build job from the artifact-upload example in the same workflow run. File presence is demonstrated; production provenance verification needs additional checks.

.github/workflows/checks.yml
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
jobs:
  inspect:
    needs: build
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
        with:
          name: example-${{ github.sha }}
          path: dist
      - run: test -s dist/example.txt