CI with an API key
The CLI in continuous integration: OWBASE_API_KEY, OWBASE_PROJECT_ID, and OWBASE_ENDPOINT, key scopes, and a GitHub Actions example.
In CI there is no login: the CLI authenticates with a project API key, passed through an environment variable. When it is set, the key overrides any session, is never written to ~/.owbase/, and is valid only for its own project.
| Variable | What |
|---|---|
OWBASE_API_KEY |
the API key (a CI secret) |
OWBASE_PROJECT_ID |
the project ID (overrides the projectId in owbase.json) |
OWBASE_ENDPOINT |
optional; the default is https://cloud.owbase.dev/v1 |
The key goes only to OWBASE_ENDPOINT or, without it, to https://cloud.owbase.dev/v1; never to the address of a saved session. If owbase.json has a different endpoint, the CLI refuses without making any request: set OWBASE_ENDPOINT to the same value to confirm. http:// is only accepted for localhost; anywhere else, the key is only sent over https://, with the certificate verified.
owbase.json goes in the repository
Section titled “owbase.json goes in the repository”CI does not run owbase init: it uses the owbase.json that you versioned along with the code (the functions/ and sites/ folders too). Create it on your machine with owbase init project and owbase init function or owbase init site, and commit it.
The push applies the file’s settings on the server, and a missing field goes back to its default: see The owbase.json file.
Generate owbase.json in CI
Section titled “Generate owbase.json in CI”A site (or a function) that already exists in the project becomes an owbase.json entry with pull, also with just the key, without a login:
OWBASE_PROJECT_ID=<PROJECT_ID> owbase pull site --site-id <SITE_ID> --no-codeOWBASE_PROJECT_ID=<PROJECT_ID> owbase pull function --function-id <FUNCTION_ID> --no-code(with OWBASE_API_KEY set in the environment, as in the example below). Without an owbase.json in the folder, the pull creates one, with the projectId and the requested resource; with the file, it updates only that resource’s entry. --no-code pulls only the configuration; without it, the pull also downloads the code of the latest deployment and, without a terminal, asks for --force, which overwrites the resource’s folder.
Key scopes
Section titled “Key scopes”Create the key in the console (Settings → API keys) with only what the CI task does:
| Task | Scopes |
|---|---|
push function |
functions.read, functions.write, rules.read; optional: rules.write |
push site |
sites.read, sites.write, rules.read; optional: rules.write |
pull site |
sites.read |
pull function |
functions.read; optional: rules.read (pulls the <name>.fn.owbase.dev address) |
functions create-execution |
execution.write |
push table |
databases.read, databases.write, tables.read, tables.write, columns.read, columns.write, indexes.read, indexes.write |
push bucket |
buckets.read, buckets.write |
data import, data export, data undo |
tables.read, rows.read, keys.write; import and undo also need rows.write (see Import and export data) |
With rules.write, the first push creates the <id>.fn.owbase.dev or <id>.sites.owbase.dev address, as it does on your machine. Without that scope, the push warns and the deployment proceeds without an address: create it in the console or do the first push with a login. Without rules.read, the push also just warns and proceeds (it neither checks nor creates the address). With OWBASE_ENDPOINT pointing to another server, the address is not created by the key.
GitHub Actions
Section titled “GitHub Actions”name: deployon: push: branches: [main]
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 22 } - run: npm i -g @owbase/cli@1 - name: publish the function env: OWBASE_API_KEY: ${{ secrets.OWBASE_API_KEY }} OWBASE_PROJECT_ID: <PROJECT_ID> run: owbase push function --function-id orders --force@owbase/cli@1pins the major version: a version 2 does not get in unless you change the workflow.--forceanswers “yes” to the confirmations. On apush table, that includes deleting what is not inowbase.json(see Database and Storage).- For a site:
owbase push site --site-id <ID> --force, with the site scopes. Since CLI 1.4.0,pushexits with an error (failing the step) when any resource build fails; on 1.3 it exited 0, and you had to check for theSuccessfully deployedline in the output.
To check, in a manual job, whether the versioned owbase.json still matches the server (for example, after changing something in the console):
name: check-owbase-jsonon: workflow_dispatch
jobs: check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: { node-version: 22 } - run: npm i -g @owbase/cli@1 - name: pull the site from the server env: OWBASE_API_KEY: ${{ secrets.OWBASE_API_KEY }} OWBASE_PROJECT_ID: <PROJECT_ID> run: owbase pull site --site-id <SITE_ID> --no-code - run: git diff --exit-code owbase.jsonThe last step fails and shows the difference when the server has changed: update the file on your machine with the same pull and commit it before the next push.