- Database GitOps with GitHub Actions
- Database GitOps with Azure DevOps Pipeline (this one)
- Database GitOps with GitLab CI
- Database GitOps with Bitbucket Pipelines
This tutorial shows you how to build a database GitOps workflow using Azure DevOps Pipeline and Bytebase API. You’ll learn to create a streamlined database release workflow where you can:
- Submit SQL migrations through Azure DevOps
- Automatically run SQL reviews on pull requests
- Auto-create and deploy Bytebase releases when merging to
main
Prerequisites
- A Bytebase instance (Bytebase Cloud or self-hosted)
- For self-hosted version, you need Docker to run Bytebase
Automatic Rollout across environments
Step 1 - Set up Bytebase
- Cloud
- Self-Hosted
Use Bytebase Cloud for instant setup without infrastructure management. CI/CD services can connect immediately.Best for: Quick testing, evaluation, and small teams
Step 2 - Create Service Account
-
Log in as
Workspace Admin, and go to IAM & Admin > Users & Groups. Click + Add User, fill in withapi-sample, and assign theWorkspace MemberandGitOps Service Agentroles, which are sufficient for this tutorial, then click Confirm. -
Find the newly created service account and Copy Service Key. We will use this token to authenticate the API calls.

Step 3 - Configure SQL Review in Bytebase
Since you will need to run SQL review on your PRs, you need to configure the SQL review in Bytebase.- Go to CI/CD > SQL Review, click Create SQL Review.
-
Select the
Sample Templateand click Next.
-
Select
Prodenvironment as the attached resources and click Confirm. Now the SQL review is enabled for theProdenvironment.
Step 4 - Copy from the Example Repository and Configure Variables
-
Create a new project. Copy
pipelinesfolder from https://dev.azure.com/bytebase-hq/_git/bytebase-example. There are two workflows in this repository:pipelines/sql-review.yml: Lint the SQL migration files after the PR is created.pipelines/rollout-release.yml: Create a release in Bytebase after the PR is merged to themainbranch.
-
Go into
pipelines/sql-review.ymlandpipelines/rollout-release.yml. In theenvsection, replace the variable values with your own and commit the changes.- BYTEBASE_URL: Your Bytebase instance URL (e.g.,
https://bytebase.your-company.comor your Bytebase Cloud URL) - BYTEBASE_SERVICE_ACCOUNT:
api-example@service.bytebase.com(the service account you created in the previous step) - BYTEBASE_PROJECT:
projects/project-sample(the sample project in the Bytebase) - BYTEBASE_TARGETS:
instances/test-sample-instance/databases/hr_test,instances/prod-sample-instance/databases/hr_prod(the two default databases in the sample project) - FILE_PATTERN:
migrations/*.sql(the pattern of the migration files)
- BYTEBASE_URL: Your Bytebase instance URL (e.g.,
-
Go to branch policy for
mainbranch, addcheck-releaseas a required check. You don’t need to addrollout-releaseas a required check because it will be triggered automatically when the PR is merged.

pipelines/rollout-release.yml, pay attention to BYTEBASE_TARGETS in deploy-to-test stage. You should put all the databases including both Test and Prod environments. NOT ONLY the Test database.
Step 5 - Create the migration files
To create migration files to trigger release creation, the files have to match the following pattern:- A migration file should start with digits, which is also its version. e.g.
202503131500_create_table_t1_ddl.sql. - A migration file may end with ‘ddl’ or ‘dml’ to indicate its change type. If it doesn’t end with any of the two, its change type is DDL by default.
-
Within your forked repository, create the following migration files under
migrationsdirectory:- 202503131500_create_table_t1_ddl.sql
-
Commit to a new branch and create a pull request, the
check-releaseworkflow will be triggered. There will be a warning in the SQL review result.

-
According to the SQL review result, you can do some changes to the SQL files and push to the branch. Then you should see the SQL review has passed. There are no warnings in the SQL review result.

-
When the SQL review is passed, you can merge the pull request. The
rollout-releaseworkflow will be triggered to create a release in Bytebase and then deploy automatically.
-
You need to permit the release to be deployed to the production environment the first time.


-
If you click the test stage and expand the different sections, you can follow the links to Bytebase.

- You may customize the workflow file to trigger deployment manually according to your needs.

