Skip to main content

Announce deploys from CI

Tell SchemaBounce your service was deployed, from GitHub Actions, GitLab CI, CircleCI, Buildkite, Bitbucket, Azure Pipelines, Jenkins or Argo CD, with OIDC or a revocable deploy token.

Your CI makes one authenticated call after it deploys. That call is a hint: it makes SchemaBounce read the service now instead of on the next poll. It never counts as proof. The platform still reads the running commit from your app (see Version endpoint examples).

Without announcements verify still works. SchemaBounce reads a service while a session waits on it, only more slowly.

The call​

POST https://api.schemabounce.com/api/v1/environments/<env_id>/deployments
Authorization: Bearer <OIDC token or deploy token>
Content-Type: application/json

{
"service": "web",
"commit": "0123456789abcdef0123456789abcdef01234567",
"status": "success",
"url": "https://app.example.com",
"ciRunUrl": "https://github.com/acme/web/actions/runs/1"
}
  • service and commit are required. commit is 7 to 64 hex characters.
  • status is lowercase letters, digits, - or _, 40 characters at most. success is the usual value.
  • url and ciRunUrl are optional HTTPS URLs, 2048 characters at most.
  • The answer is 202 with observationId, serviceId and checkScheduled.
  • A refusal for an unknown environment, an untrusted repository or a token of another environment looks the same to the caller. Find the cause in the Environment's Trusted CI list.

The environment id (env_...) is on the Environment's page. The service must already exist on the Services tab.

Sign in without a secret: OIDC​

Each CI provider can give a job a short-lived identity token. Add the project on the Environment's Trusted CI tab, and the job needs no stored secret. The token's audience must be schemabounce. A token minted for any other audience is refused, even from a trusted project.

ProviderGet a tokenTrust entry matches on
GitHub Actionsid-token: write, token with audience=schemabounceRepository, with optional workflows, branches and GitHub environment
GitLab CIid_tokens: SB_ID_TOKEN: {aud: schemabounce}Numeric project id. The project path is shown, never matched.
CircleCIcircleci run oidc get --claims '{"aud":"schemabounce"}'Project id, under your organization's issuer https://oidc.circleci.com/org/<org-id>
Buildkitebuildkite-agent oidc request-token --audience schemabounceOrganization id and pipeline id. Slugs are shown, never matched.

Notes:

  • Only immutable ids are matched, because a path or slug can be renamed or reused by someone else.
  • A self-managed GitLab uses its own https:// address as the issuer on the trust entry.
  • Buildkite's branch is chosen by whoever triggers the build, so a branch list on a Buildkite entry is a convenience, not a control. CircleCI tokens carry no branch.
  • The CircleCI token command and key location come from secondary sources and have not yet been confirmed against a live CircleCI token. Use a deploy token for CircleCI until that is confirmed.
  • Azure DevOps tokens carry a fixed audience that cannot be set, so SchemaBounce does not accept them. Azure Pipelines uses a deploy token.

Sign in with a deploy token​

For a CI tool without OIDC, create a token on the Environment's Services tab under Deploy tokens.

  • The token starts with sbdeploy_. It is shown once. SchemaBounce stores only a hash.
  • A token belongs to one Environment. Revoke it on the same tab and the next announcement fails.
  • A leaked token can start extra version reads and nothing else, because an announcement is never proof.
  • Keep it in your CI's secret store. Never write it in a file.

Templates​

The templates live in the core-api repository under ci-kit/. Replace ENV_ID and SERVICE.

ToolFileSign-in
GitHub Actionsci-kit/github/announce-deploy/action.ymlOIDC, deploy token as fallback
GitLab CIci-kit/templates/gitlab-ci.ymlOIDC, deploy token as fallback
CircleCIci-kit/templates/circleci-config.ymlOIDC, deploy token as fallback
Buildkiteci-kit/templates/buildkite-pipeline.ymlOIDC, deploy token as fallback
Bitbucket Pipelinesci-kit/templates/bitbucket-pipelines.ymlDeploy token
Azure Pipelinesci-kit/templates/azure-pipelines.ymlDeploy token
Jenkinsci-kit/templates/JenkinsfileDeploy token
Argo CD Notificationsci-kit/templates/argocd-notifications.yamlDeploy token

Every template retries 5xx and network errors, and the GitHub action never prints either token.

GitHub Actions​

The public action SchemaBounce/announce-deploy@v1 is not published yet. Until it is, use the action from ci-kit/github/announce-deploy in core-api, or this step, which does the same thing:

permissions:
id-token: write
contents: read

steps:
- name: Announce deploy to SchemaBounce
run: |
TOKEN="$(curl -sS -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=schemabounce" | jq -r .value)"
curl --fail-with-body --retry 3 -sS -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
"https://api.schemabounce.com/api/v1/environments/ENV_ID/deployments" \
-d "{\"service\":\"web\",\"commit\":\"$GITHUB_SHA\",\"status\":\"success\"}"

Run it after your deploy job succeeds, not before. The action takes the inputs environment-id, service, commit (default github.sha), status (default success), url, api-url and deploy-token.

GitLab CI​

announce-deploy:
stage: .post
id_tokens:
SB_ID_TOKEN:
aud: schemabounce
image: curlimages/curl:8.10.1
script:
- |
curl --fail-with-body --retry 3 -sS -X POST \
-H "Authorization: Bearer ${SB_ID_TOKEN:-$SCHEMABOUNCE_DEPLOY_TOKEN}" \
-H "Content-Type: application/json" \
"https://api.schemabounce.com/api/v1/environments/ENV_ID/deployments" \
-d "{\"service\":\"SERVICE\",\"commit\":\"${CI_COMMIT_SHA}\",\"status\":\"success\"}"

CircleCI​

Add SCHEMABOUNCE_DEPLOY_TOKEN as a project environment variable. Use the deploy token for CircleCI for now. CircleCI's OIDC token has not been confirmed against a live CircleCI account, so the template tries OIDC first and falls back to the token. Do not rely on the OIDC path.

version: 2.1
jobs:
announce-deploy:
docker:
- image: cimg/base:2024.10
steps:
- run:
name: Announce deploy to SchemaBounce
command: |
SB_TOKEN="$(circleci run oidc get --claims '{"aud":"schemabounce"}' 2>/dev/null || true)"
SB_TOKEN="${SB_TOKEN:-$SCHEMABOUNCE_DEPLOY_TOKEN}"
curl --fail-with-body --retry 3 --retry-connrefused -sS -X POST \
-H "Authorization: Bearer ${SB_TOKEN}" \
-H "Content-Type: application/json" \
"https://api.schemabounce.com/api/v1/environments/ENV_ID/deployments" \
-d "{\"service\":\"SERVICE\",\"commit\":\"${CIRCLE_SHA1}\",\"status\":\"success\",\"ciRunUrl\":\"${CIRCLE_BUILD_URL}\"}"
workflows:
deploy:
jobs:
- announce-deploy

Buildkite​

The doubled $$ stops Buildkite from interpolating at upload time. The shell expands the value when the step runs.

steps:
- label: "Announce deploy to SchemaBounce"
command: |
SB_TOKEN="$$(buildkite-agent oidc request-token --audience schemabounce 2>/dev/null || true)"
SB_TOKEN="$${SB_TOKEN:-$${SCHEMABOUNCE_DEPLOY_TOKEN}}"
curl --fail-with-body --retry 3 --retry-connrefused -sS -X POST \
-H "Authorization: Bearer $${SB_TOKEN}" \
-H "Content-Type: application/json" \
"https://api.schemabounce.com/api/v1/environments/ENV_ID/deployments" \
-d "{\"service\":\"SERVICE\",\"commit\":\"$${BUILDKITE_COMMIT}\",\"status\":\"success\",\"ciRunUrl\":\"$${BUILDKITE_BUILD_URL}\"}"

Deploy token with curl: Jenkins, Azure DevOps, Bitbucket and anything else​

A tool without a usable OIDC token sends the same call with a deploy token. Keep the token in the tool's secret store.

Jenkins, with a "Secret text" credential whose id is schemabounce-deploy-token:

pipeline {
agent any
stages {
stage('Announce deploy') {
steps {
withCredentials([string(credentialsId: 'schemabounce-deploy-token', variable: 'SCHEMABOUNCE_DEPLOY_TOKEN')]) {
sh '''
curl --fail-with-body --retry 3 --retry-connrefused -sS -X POST \
-H "Authorization: Bearer ${SCHEMABOUNCE_DEPLOY_TOKEN}" \
-H "Content-Type: application/json" \
"https://api.schemabounce.com/api/v1/environments/ENV_ID/deployments" \
-d "{\"service\":\"SERVICE\",\"commit\":\"${GIT_COMMIT}\",\"status\":\"success\",\"ciRunUrl\":\"${BUILD_URL}\"}"
'''
}
}
}
}
}

Azure Pipelines, with a secret pipeline variable (Azure DevOps tokens carry a fixed audience that SchemaBounce does not accept):

steps:
- script: |
curl --fail-with-body --retry 3 --retry-connrefused -sS -X POST \
-H "Authorization: Bearer $SCHEMABOUNCE_DEPLOY_TOKEN" \
-H "Content-Type: application/json" \
"https://api.schemabounce.com/api/v1/environments/ENV_ID/deployments" \
-d "{\"service\":\"SERVICE\",\"commit\":\"$(Build.SourceVersion)\",\"status\":\"success\"}"
displayName: Announce deploy to SchemaBounce
env:
SCHEMABOUNCE_DEPLOY_TOKEN: $(SCHEMABOUNCE_DEPLOY_TOKEN)

Bitbucket Pipelines, with a secured repository variable:

pipelines:
branches:
main:
- step:
name: Announce deploy to SchemaBounce
image: curlimages/curl:8.10.1
script:
- |
curl --fail-with-body --retry 3 --retry-connrefused -sS -X POST \
-H "Authorization: Bearer ${SCHEMABOUNCE_DEPLOY_TOKEN}" \
-H "Content-Type: application/json" \
"https://api.schemabounce.com/api/v1/environments/ENV_ID/deployments" \
-d "{\"service\":\"SERVICE\",\"commit\":\"${BITBUCKET_COMMIT}\",\"status\":\"success\"}"

GitHub deployment events​

If your repository's GitHub App sends deployment_status events to SchemaBounce, each one is treated as an announcement. It also starts a read and is never proof.

Deploys without CI: Argo CD and Flux​

A GitOps tool deploys from a cluster, not from a pipeline. You have three choices. The first two are optional speed-ups.

1. Argo CD Notifications. Argo CD can send the call when a sync succeeds and the app is healthy. Put the deploy token in argocd-notifications-secret under the key schemabounce-deploy-token, then add this to argocd-notifications-cm. Replace ENV_ID and SERVICE:

apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.webhook.schemabounce: |
url: https://api.schemabounce.com
headers:
- name: Authorization
value: Bearer $schemabounce-deploy-token
- name: Content-Type
value: application/json
template.schemabounce-deployed: |
webhook:
schemabounce:
method: POST
path: /api/v1/environments/ENV_ID/deployments
body: |
{"service":"SERVICE","commit":"{{.app.status.operationState.syncResult.revision}}","status":"success"}
trigger.on-deployed: |
- when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
oncePer: app.status.operationState.syncResult.revision
send: [schemabounce-deployed]

Subscribe an Application with the annotation notifications.argoproj.io/subscribe.on-deployed.schemabounce: "".

The revision Argo CD reports is the commit of your manifests repository, which is often not the application commit. That is safe, because an announcement is only a hint that starts a read. What matters is that your app's version endpoint serves the application commit.

2. Flux. Flux's notification provider sends its own event body, not the body this call needs, so it cannot make the call by itself. Run the call from a post-deploy step you control, such as a Job that runs the curl command above, or use the third choice.

3. The observer alone. Do nothing. While a session waits, SchemaBounce reads each service every 30 seconds, so the session sees the deploy within one read plus stableReads reads. This works for every tool, Argo CD and Flux included, at the cost of up to half a minute.

In all three cases the proof is the same: the app reports the landed commit. Which tool deployed it does not matter.

Not yet available​

  • The public action SchemaBounce/announce-deploy@v1. Use the template path above.
  • Provider-shaped webhook receivers for hosts such as Vercel or Netlify. Polling covers them in the meantime.

Continue exploring