CI and automation
Publish a theme from GitHub Actions or any CI with an environment variable.
In CI the CLI reads the key from OPENSTOCK_API_KEY, so there is nothing to log in to. Use a dedicated key with only the Theme code: Write and Store details: Read scopes, and pass --yes because there is nobody to answer the confirmation.
GitHub Actions#
name: Publish theme
on:
push:
branches: [main]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npx @openstock/cli publish --yes --force
env:
OPENSTOCK_API_KEY: ${{ secrets.OPENSTOCK_API_KEY }}--force makes the repository the source of truth: it overwrites drafts that were edited in the dashboard. Leave it out if you want the job to fail instead.
Exit codes#
| Code | Meaning |
|---|---|
| 0 | Success. |
| 1 | The command failed: bad key, missing scope, conflict or build error. |
| 2 | Unknown command or option. |