Automate deploys (CI/CD)
CI/CD (“continuous integration / continuous delivery”) means letting a pipeline —
GitHub Actions, GitLab CI, a build server, or any script — build and ship your app
automatically instead of running deploys by hand from your laptop. On Comwit Cloud
this works the same way a manual deploy does: your automation authenticates with a
token and calls the platform API at https://api.cloud.comwit.io, either through
the comwit CLI or with raw HTTP.
This page covers the pieces that are the same no matter which CI system you use: the token, the build artifact, and the two integration styles. For copy-paste workflows, see GitHub Actions and other CI systems.
Use a scoped cwt_ token
Section titled “Use a scoped cwt_ token”Automation authenticates with a personal access token — a cwt_ token. It is
tied to your user, can only act on projects you are a member of, and can only
do what its scopes allow. That makes it safe to drop into a pipeline: even if
the secret leaked, it can only do the narrow set of things you granted.
For deploy automation you almost always want one of two scopes:
| Scope | Grants |
|---|---|
app:deploy | Deploy builds, roll back |
app:write | Create/delete apps, set env, attach hostnames |
If your pipeline only ships new builds of an app that already exists, app:deploy
is enough. If the pipeline also creates the app, sets environment variables, or
attaches hostnames, add app:write. (app:read lets a pipeline list apps and
inspect builds if you need that for a check.) See
Authentication for the full scope table.
Create the token
Section titled “Create the token”Create a scoped cwt_ token from the console at
https://cloud.comwit.io/tokens (“API tokens”).
Pick the scopes your pipeline needs and nothing more. The plaintext token is shown
once at creation — copy it then. You can revoke it from the same page at any
time.
Store it as a CI secret
Section titled “Store it as a CI secret”Save the cwt_ token as an encrypted secret in your CI provider — never commit it
to your repository or print it in build logs. Most providers expose secrets to the
build as environment variables; a common convention is COMWIT_TOKEN.
The build artifact
Section titled “The build artifact”A deploy ships one build artifact: your app’s compiled output. Comwit accepts it in two shapes:
- a directory of build output (a brrrd output directory), or
- a prebuilt
.tar.zstpackage file.
When you point the CLI at a directory, it packs the directory into a temporary
.tar.zst for you using local tar --zstd. If your CI image’s tar does not
support zstd, build the .tar.zst yourself (or have your build step produce one)
and pass that file instead.
Over raw HTTP there is no directory upload: the deployment request body is the raw
application/octet-stream .tar.zst artifact.
Two integration styles
Section titled “Two integration styles”A. Run the comwit CLI in CI
Section titled “A. Run the comwit CLI in CI”The friendliest option when you can install a binary in your pipeline. Authenticate
non-interactively with --token (no browser device flow in CI), then deploy.
# Authenticate with the token from your CI secret store.comwit login --token "$COMWIT_TOKEN" --project "$COMWIT_PROJECT"
# Build artifact is a directory or a prebuilt .tar.zst.comwit deploy \ --project "$COMWIT_PROJECT" \ --app "$COMWIT_APP" \ --package ./apps/web/dist/brrrdcomwit login --token stores the token in the CLI config instead of running the
interactive device flow, so it works headless. You can also pass the project with
the COMWIT_PROJECT environment variable instead of --project.
comwit deploy accepts the same optional flags in CI as anywhere else:
comwit deploy \ --project "$COMWIT_PROJECT" \ --app "$COMWIT_APP" \ --package ./dist/brrrd \ --host app.example.com \ --env-ref brrrd/env/app \ --max-concurrent-requests 100For installing the binary in a pipeline, see Install the CLI.
B. Call the API over raw HTTP
Section titled “B. Call the API over raw HTTP”Use this when installing the CLI is awkward — a minimal container image, a platform
where you can only run curl, or tooling in another language. Send the token as a
bearer header and POST the .tar.zst artifact as the raw request body. Hosts,
env-ref, and concurrency go on the query string (not in the body).
curl -sS -X POST \ -H "Authorization: Bearer $COMWIT_TOKEN" \ -H "Content-Type: application/octet-stream" \ --data-binary @./dist/brrrd.tar.zst \ "https://api.cloud.comwit.io/v1/projects/$COMWIT_PROJECT/apps/$COMWIT_APP/deployments"The deploy endpoint is:
POST /v1/projects/{projectId}/apps/{appId}/deploymentsA request whose token lacks the required scope, or that targets a project you are
not a member of, returns 403. For the full status-code list and retry behavior,
see Errors and idempotency and the
API overview.
Next steps
Section titled “Next steps”- GitHub Actions — a ready-to-use workflow.
- Other CI systems — GitLab CI, build servers, and raw-HTTP patterns.
- App deploys — what a deploy does and how rollbacks work.
- Authentication — token classes and the full scope table.