Sub topic 14
Approvals, versioning, and rollback
This chapter assumes you have a working CD workflow that deploys a bundle to staging and runs integration tests. It also assumes you know the bundle targets from the earlier chapters. Here you add three controls to the production step: a human approval, a version you can name, and a way back when a release is bad.
Require approval before production
Staging can deploy automatically. Production should wait for a person. GitHub Actions supports this with an environment. You create an environment named production in the repository settings and add required reviewers. Any job that declares environment: production pauses until a reviewer approves it.
Environments also hold secrets and variables. Store the production service principal credentials on the production environment, not at repository level. Then only jobs that passed the approval gate can read them.
Version releases with Git tags
A bundle deploys whatever is in your checkout, so "version 1.4.0" needs a definition. The simplest one is a Git tag. Tag a commit on main that already passed staging, and deploy production from that tag only.
This gives you a fixed, reviewable artifact. It also gives you a rollback target, because every earlier tag is still there.
name: release
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
ref:
description: Tag to deploy, for example v1.3.0
required: true
jobs:
deploy-prod:
runs-on: ubuntu-latest
environment: production
env:
DATABRICKS_HOST: ${{ vars.DATABRICKS_HOST }}
DATABRICKS_CLIENT_ID: ${{ secrets.DATABRICKS_CLIENT_ID }}
DATABRICKS_CLIENT_SECRET: ${{ secrets.DATABRICKS_CLIENT_SECRET }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- uses: databricks/setup-cli@main
- run: databricks bundle validate -t prod
- run: databricks bundle deploy -t prodPushing a tag starts the workflow, and the production environment holds it for approval. Running it manually with an older tag deploys that older version. The same file handles both release and rollback.
Roll back by redeploying
Bundle deployment is declarative. It compares the bundle in your checkout with what exists in the workspace and updates the workspace to match. Deploying the previous tag therefore restores the earlier job definitions, task code, and settings. You do not need a special rollback command.
Two cautions apply:
- Deploy the old tag through the same pipeline, with the same approval. A rollback made from a laptop skips the audit trail.
- Pin dependencies, such as wheel versions in job libraries. Otherwise an old tag can still pull new package versions and behave differently.
What rollback does not undo
Redeploying code does not reverse data changes. If version 1.4.0 wrote bad rows or changed a table schema, version 1.3.0 inherits that table. Delta tables keep a history, so you can restore a table separately:
DESCRIBE HISTORY main.sales.orders;
RESTORE TABLE main.sales.orders TO VERSION AS OF 42;Restoring is a data decision, so do it deliberately and not as an automatic part of the pipeline. Downstream consumers may have already read the bad data.
The best protection is to make releases rollback-safe in the first place:
- Prefer additive schema changes, such as new nullable columns, over renames and drops.
- Run the data quality checks from the earlier chapter as the last task in the job, so a bad run fails loudly.
- Keep the retention period of Delta history long enough to cover your detection time.
Exercise
Version 1.4.0 is deployed to production and its job writes incorrect values into a Delta table. Name the two separate actions needed to recover, and say why one action alone is not enough.
Show answer
First, run the release workflow manually with the previous tag, for example v1.3.0, so the job code and definitions return to the earlier version. Second, restore the affected table with RESTORE TABLE to a version from before the bad run. Redeploying the bundle only replaces code and job settings. It does not change data already written, so the table still contains the incorrect values until you restore it.