CI/CD Automation

Zephyr requires authenticated CI/CD pipelines to publish updates. Use CI tokens for deployment authentication.

Deployment auth recommendation

CI tokens are the recommended way to authenticate deployments. Pipelines that use personal tokens or server tokens still work, but using them for deployments is planned for deprecation. See the migration guide.

Creating a CI Token

First, create a CI token from Settings → Tokens → CI Tokens. This token will be used to authenticate your CI/CD pipeline with Zephyr. See CI Tokens for how tokens are exchanged, which CI providers are supported, and how deployments are attributed.

GitHub Actions

Adding the GitHub Secret

Add your Zephyr token as a repository secret:

  1. Navigate to your GitHub repository
  2. Go to Settings → Secrets and variables → Actions
  3. Click New repository secret
  4. Set:
    • Name: ZEPHYR_CI_TOKEN
    • Secret: Your Zephyr CI token

Using in Workflow

The secret must be assigned to the ZE_CI_TOKEN environment variable:

.github/workflows/deploy.yml
name: Deploy with Zephyr
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      ZE_CI_TOKEN: ${{ secrets.ZEPHYR_CI_TOKEN }}
      ZE_FAIL_BUILD: true

    steps:
      - uses: actions/checkout@v3
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '20'

      - name: Install dependencies
        run: npm ci

      - name: Build and deploy
        run: npm run build

GitLab CI/CD

Adding the GitLab Variable

Add your Zephyr token as a CI/CD variable:

  1. Navigate to your GitLab project
  2. Go to Settings → CI/CD
  3. Expand the Variables section
  4. Click Add variable
  5. Set:
    • Key: ZE_CI_TOKEN
    • Value: Your Zephyr CI token
    • Type: Variable
    • Environment scope: All (or specify environments)
    • Protect variable: ✓ (recommended)
    • Mask variable: ✓ (recommended)

Using in Pipeline

.gitlab-ci.yml
stages:
  - install
  - build
  - deploy

variables:
  npm_config_cache: '$CI_PROJECT_DIR/.npm'

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .npm/
    - node_modules/

install:
  stage: install
  script:
    - npm ci --cache .npm --prefer-offline
  artifacts:
    paths:
      - node_modules/
    expire_in: 1 hour

build:
  stage: build
  script:
    - npm run build
  variables:
    ZE_CI_TOKEN: $ZE_CI_TOKEN
    ZE_FAIL_BUILD: true
  artifacts:
    paths:
      - dist/
    expire_in: 1 day

deploy:
  stage: deploy
  script:
    - npm run deploy
  only:
    - main
  environment:
    name: production
  variables:
    ZE_CI_TOKEN: $ZE_CI_TOKEN
    ZE_FAIL_BUILD: true

Fail the build on Zephyr errors

When a Zephyr step fails, Zephyr either fails your build or logs the error and lets the build finish without a deploy. It decides in this order:

  1. The failBuild option of withZephyr, when you set it (webpack and Rspack plugins).
  2. ZE_FAIL_BUILD. The value true fails the build. Any other value logs the error.
  3. When neither is set, the build fails in CI when ZE_CI_TOKEN is set. Everywhere else, Zephyr logs the error.
ZE_FAIL_BUILD=true npm run build

Set ZE_FAIL_BUILD=false to log errors instead of failing, also in CI.

This applies to single configurations, compiler arrays, coordinated multi-compiler builds, and remote dependency lookups. When the build continues, the bundle is built but not deployed.

If Zephyr cannot be reached (network, DNS, timeout, or an HTTP 5xx response), the error is ZE50001. It can also appear as the Reason of another code, such as ZE20014.

Build without Zephyr

Set ZE_DISABLED=true to build without Zephyr, for example during a Zephyr outage or in a fork that has no token:

ZE_DISABLED=true npm run build

The plugins and ze-cli then skip every Zephyr step. They make no network requests and need no token. The bundle is built, and the output ends with this line:

The bundle is built. The bundle is not deployed. Zephyr is disabled (ZE_DISABLED).

Only the value true enables this mode. Nothing turns it on automatically.

Plugin Behavior

When the Zephyr plugin detects the ZE_CI_TOKEN environment variable, it will:

  1. Use the token for automatic authentication
  2. Skip the interactive login step
  3. Display this message in the console:
 ZEPHYR   Token found in environment. Using CI token for authentication

Troubleshooting

Token not found

  • Ensure the variable name is exactly ZE_CI_TOKEN
  • Verify the variable is available in the job environment
  • Check that the token hasn't expired

GitHub Actions Issues

  • Make sure the secret is added to the correct repository
  • Verify the secret name matches what's referenced in the workflow

GitLab CI/CD Issues

  • If using protected variables, ensure your pipeline runs on protected branches
  • Masked variables won't appear in logs (recommended for security)
  • Check variable scope matches your branch/environment