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.

Trust & credentials

Grant the minimum job authority explicitly

GitHub Actions

permissions scopes GITHUB_TOKEN authority. When you specify individual permissions, omitted permissions are set to none; repository/org policies can further constrain the result.

Fragment

Top-level workflow permission block. Some jobs may need explicitly reviewed additional permissions.

.github/workflows/checks.yml
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
permissions:
  contents: read

Inject secrets without printing or committing them

GitHub Actions

Read a configured secret through its supported context into an environment value. Missing secrets can resolve to empty strings. Masking is not a complete data-loss prevention boundary.

Fragment

Steps-list fragment. Configure API_TOKEN outside this file; the command checks presence without printing the value.

.github/workflows/checks.yml
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
# Step fragment:
- env:
    API_TOKEN: ${{ secrets.API_TOKEN }}
  run: test -n "$API_TOKEN"

Keep event data out of shell source

GitHub Actions

Untrusted event fields can become script injection if interpolated directly into run source. Pass values as environment data and quote their use; validate them for the operation you perform.

Fragment

Steps-list fragment for a pull_request job using Bash. This demonstrates a length check without interpreting the title as shell code.

.github/workflows/checks.yml
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
# Pull-request step fragment:
- env:
    PR_TITLE: ${{ github.event.pull_request.title }}
  run: test "${#PR_TITLE}" -le 200

Separate untrusted checks from privileged workflows

GitHub Actions

Fork pull_request workflows normally have restricted tokens/secrets, subject to repository policy. pull_request_target uses the base-repository context; do not combine its privileges with executing untrusted pull-request code.

Protocol / decision sketch

Trust-boundary sketch; inspect actual repository/org settings, runner trust and event semantics.

.github/workflows/checks.yml
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
untrusted contribution → isolated checks without sensitive authority
trusted release         → separately authorized workflow

Pin executable workflow dependencies to a reviewed identity

GitHub Actions

A full commit SHA fixes the referenced action revision; a moving major tag can change. Review the publisher and code, and maintain updates rather than assuming a pin remains secure forever.

Fragment

Steps-list fragment; pin resolution is recorded in the reference metadata and should be re-reviewed over time.

.github/workflows/checks.yml
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
# Step fragment, official checkout v7.0.1 tag resolved 2026-11-07:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
  with:
    persist-credentials: false

Exchange a scoped workload identity for short-lived access

GitHub Actions

id-token:write permits requesting an OIDC token; it does not itself grant cloud-resource access. Configure the provider to validate intended issuer, audience and repository/ref/environment claims.

Fragment

Workflow permission fragment. A provider-specific, reviewed exchange step and trust policy are still required.

.github/workflows/checks.yml
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
permissions:
  contents: read
  id-token: write