Skip to content

Run the CLI in CI/CD ​

Use this guide when you want to run the shipped chainabit commands from a non-interactive job.

Install the CLI ​

bash
npm install -g @chainabit/cli

Provide Credentials Safely ​

For CI jobs, prefer a time-bounded developer token or an already-issued access token instead of typing passwords into the command line.

Option 1: Reuse an Existing Token ​

Configure CHAINABIT_TOKEN in the CI secret store, then check the resolved identity:

bash
chainabit auth whoami --json

CHAINABIT_TOKEN works with any API address. A saved sign-in is sent only to the API address it was created on, so a job that targets a different API address needs its own token.

Option 2: Log In with a Developer Token ​

bash
chainabit auth login \
  --token-env CHAINABIT_DEVELOPER_TOKEN

The CLI authenticates with the developer token and keeps it in your configuration for later commands.

Verify the Workspace Context ​

Use --json so the pipeline can parse structured output.

bash
chainabit auth whoami --json
chainabit workspace current --json

Expected result: authentication succeeds for the intended account and the resolved workspace ID matches your job. workspace current reads local context; use workspace list --json when you also need to check server-side workspace access. Do not hardcode example user IDs or expiry timestamps into a pipeline assertion.

Run Real Commands ​

Once authenticated, you can inspect workspace state, connectors, and AI metadata from the job:

bash
chainabit chain list --json
chainabit connectors list --json
chainabit ai models --json

Read the returned catalog for your account rather than assuming a connector is installed, authorized, or available because it appears in a sample. Each command still requires its own scope and resource access.

Example GitHub Actions Workflow ​

yaml
name: Chainabit check
on: [push]

jobs:
  verify:
    runs-on: ubuntu-latest
    env:
      CHAINABIT_BASE_URL: https://api.chainabit.com/api/v1
      CHAINABIT_WORKSPACE_ID: ${{ secrets.CHAINABIT_WORKSPACE_ID }}
      CHAINABIT_DEVELOPER_TOKEN: ${{ secrets.CHAINABIT_DEVELOPER_TOKEN }}
    steps:
      - uses: actions/checkout@v4
      - run: npm install -g @chainabit/cli
      - run: chainabit auth login --token-env CHAINABIT_DEVELOPER_TOKEN
      - run: chainabit auth whoami --json
      - run: chainabit workspace current --json
      - run: chainabit connectors list --json
      - run: chainabit ai models --json

Creating the Token ​

Create the CI token from a trusted interactive session:

bash
chainabit auth keys create "github-actions" --ttl 90 --scope execution:run

Complete any password or authenticator verification prompted by the CLI. Create the key before starting the CI job; unattended jobs should use the issued key from the secret store.

Add --scope wallet:read if the job needs wallet visibility, or --account <account-uuid> if the token must stay bound to one account.

Handle failures deliberately ​

Fail the job when authentication or a required command returns a nonzero status. Keep credentials in the CI secret store, avoid echoing them, and do not upload the CLI's local config as a build artifact. Use a dedicated CHAINABIT_CONFIG_DIR if the runner keeps state between jobs.

Before adding mutations, confirm the selected workspace and the required token scopes. If a mutation times out, inspect the resulting resource before retrying: another command invocation starts a new operation.

When to Use Another Page ​

Built with purpose. chainabit.com