Skip to content
Skip to Content

Use in CI

Run the CLI in GitHub Actions, GitLab CI or any other pipeline, with an API key in OPENPANEL_TOKEN.

In a pipeline nobody can open a browser, so the CLI signs in with an API key in OPENPANEL_TOKEN. This page is the CLI's side of it; for the whole task, from making the key to deploying on every push, see Deploy from CI.

Not on npm yet

The pipelines below install the CLI from OpenPanel's own download, pinned to a version (see Install).

What a pipeline needs

  1. A key. Make one on your own computer, signed in with openpanel login. Give it the deploy scope and limit it to the project the pipeline deploys:

    openpanel keys create --name "CI" --scope deploy --project shop

    The key is printed once. Save it in your CI's secrets as OPENPANEL_TOKEN.

  2. The service. Commit the .openpanel.json that openpanel link writes, or pass --project and --service on every command.

  3. Node.js 20 or newer, to run the CLI.

The CLI reads OPENPANEL_TOKEN before anything else, so no openpanel login step is needed. A key acts as the person who made it, capped by its scope. If that person leaves the organization, the key stops working.

How the CLI behaves without a terminal

  • Destructive steps need --yes. Deleting a project or a service, removing a volume or a domain, revoking a key and rolling back ask for confirmation. With no terminal to ask, the command stops with exit code 2 unless you pass --yes.
  • --json prints the API's JSON on standard output, for the next step to read. A failure is printed on standard error as {"error":{"message":"…","code":"…","status":403}}.
  • Exit codes are 0 done, 1 failed and 2 used wrongly.
  • openpanel deploy --wait keeps the job running until the deployment runs, and fails the job when the deployment fails. A build is stopped after 60 minutes, and a rollout that is not ready after 15.

A key limited to some projects reaches only those projects. It cannot list the organization's servers, so --server fails with it: choose the service's servers beforehand, signed in as yourself.

GitHub Actions

Deploy the commit that was pushed to main, for a service that builds from Git. Add the key under the repository's Settings, Secrets and variables, Actions, as OPENPANEL_TOKEN.

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

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: actions/setup-node@v7
        with:
          node-version: 24
      - run: npm install -g https://cdn.openpanel.sh/cli/0.1.0/openpanel-cli-0.1.0.tgz
      - run: openpanel deploy --commit "$GITHUB_SHA" --wait
        env:
          OPENPANEL_TOKEN: ${{ secrets.OPENPANEL_TOKEN }}

The checkout puts .openpanel.json where the CLI finds it. --commit makes OpenPanel build exactly the commit this run tested, even if someone pushes again meanwhile.

GitLab CI

Add the key under the project's Settings, CI/CD, Variables, as OPENPANEL_TOKEN, masked and protected.

.gitlab-ci.yml
deploy:
  stage: deploy
  image: node:24
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script:
    - npm install -g https://cdn.openpanel.sh/cli/0.1.0/openpanel-cli-0.1.0.tgz
    - openpanel deploy --commit "$CI_COMMIT_SHA" --wait

A service that runs an image

When your pipeline builds and pushes the image itself, point the service at the new tag, then deploy:

openpanel services update --image registry.example.com/acme/web:"$GITHUB_SHA"
openpanel deploy --wait

Your servers pull the image without credentials, so it must be in a public repository.

Other steps in a pipeline

# Set a variable for the next deploy; a secret's value comes from standard input
printf %s "$STRIPE_KEY" | openpanel env set STRIPE_KEY --secret

# Read the service's settings as JSON
openpanel services get --json

# Go back to the deployment before, without being asked
openpanel rollback --yes

See the command reference for every command.