Skip to main content
This guide shows how your CI pipeline builds a release from the commit it’s running on and deploys it to a customer’s deployment. It does the same as Create a release and Deploy an update in the dashboard. Who: you (the vendor), in your CI system.

Before you start

  • Your application is set up in Deployz, and a release built from the dashboard works. The API builds releases with the same settings. See Create a release.
  • The customer’s deployment is installed. The API deploys updates to existing deployments. It doesn’t install a new deployment.
  • You have an API key with Deploy permission, stored in your CI secrets. See Create and manage API keys.
  • Your CI runner has curl and jq. GitHub-hosted Ubuntu runners have both.

Find the ids

The API identifies the application and the deployment by id. Look them up once with your key, then store them as CI variables. List your applications:
List the deployments of one application:

How the pipeline works

1

Create a release

Send the release’s version and the full 40-character commit SHA to Create a release. Deployz starts the build and answers with the release. Its status is building.
2

Wait for the build

Read the release with Read one release until status is no longer building. Deploy only when it’s ready. If it’s failed, failureReason says why. See Fix build failures.
3

Deploy the release

Send the release id to Deploy a release. Deployz answers 202 with a jobId for the deploy operation.
4

Wait for the deploy

Read the operation with Read one operation until state is succeeded, failed, or cancelled. If it’s failed, failureCode names the cause. See Failure codes.

Example: GitHub Actions

This workflow builds a release on every push to main and deploys it to one deployment. workflow_dispatch also lets you start a new run from the Actions tab. Add these to your repository settings first:
  • A secret DEPLOYZ_API_KEY with your Deploy key.
  • Variables DEPLOYZ_APPLICATION_ID and DEPLOYZ_DEPLOYMENT_ID with the ids you looked up.
.github/workflows/deployz.yml
The step fails if a request fails, the build fails, or the deploy doesn’t succeed. When a request fails, the api function prints the error response to the log, including its code and request_id. See Errors and rate limits. A version can contain letters, digits, ., _, and -. This example uses the workflow’s run number. Use your own versioning scheme if you have one, such as a Git tag.

Retry safely

A pipeline can repeat a step after a timeout or a rerun without doing the work twice:
  • Create a release with the same version and commit answers 200 with the existing release instead of building again. Rerunning a GitHub Actions workflow keeps its run number and commit, so the example above reuses the release. If that release’s build failed, a rerun fails again. Fix the cause, then start a new run, which gets a new version. The same version with another commit answers 409 RELEASE_VERSION_EXISTS.
  • Deploy, restart, and rollback that find the same operation already queued or running answer 200 with the same jobId. To control this yourself, send an Idempotency-Key header with a value your pipeline chooses, such as the run id. A repeat with the same key and release returns the same operation, even after it finished. The same key with another release answers 409 IDEMPOTENCY_KEY_REUSED.

One operation at a time

A deployment runs one operation at a time. While a deploy, restart, rollback, or another operation runs, a new request answers 409 DEPLOYMENT_BUSY. Wait for the running operation to finish, then try again. Only one release of an application builds at a time. A second Create a release while a build runs answers 409 RELEASE_BUILD_IN_PROGRESS.

Deploy to several customers

Send one deploy request for each deployment. Each deployment runs its own operation, so you can start them one after another and then wait for each. To deploy one release to every deployment of an application, list them with GET /api/v1/deployments?applicationId=<id> and send a deploy for each installed one. Have your script record a refused deploy and continue with the next deployment. A deploy can’t start when a deployment isn’t installed, its connector is offline, or the release needs infrastructure the deployment doesn’t have. The API answers 409 with a code that says why. See When an update is unavailable.

Restart or roll back

Restart takes no body:
Roll back takes the id of the earlier release:
Both answer with a jobId. Wait for it the same way as a deploy. A rollback doesn’t run database migrations. Read Roll back a deployment before you automate one.