get_gitops_workflow
Generates GitOps workflow files that add a Bytebase SQL review to pull requests changing migrations and deploy on merge. Reads only; changes nothing in Bytebase.
Instructions
Return the workflow files that set up GitOps for a project. With them in the repository, every pull request that changes the migration folder gets a Bytebase SQL review, and merging it deploys. The tool reads only; it changes nothing in Bytebase.
Parameter | Required | Description |
project | Yes | The project ID, e.g. "hr" |
targets | Yes | One database group ("projects/hr/databaseGroups/all"), or one or more databases by the name ListDatabases gives ("instances/prod/databases/hr") |
workloadIdentity | Yes | The email of the workload identity the jobs sign in as |
folder | No | The folder that holds the migration files. Default "migrations" |
To set up GitOps from the team's repository:
Read the repository. The git remote gives the provider (GitHub or GitLab), the owner and the repository. Look for the folder that holds the SQL migration files.
Ask the owner which databases to deploy to. List the project's database groups and databases with call_api (DatabaseGroupService/ListDatabaseGroups, DatabaseService/ListDatabases). Offer a group first: a database that joins it later is deployed with no change to the files, when its environment is one the files already deploy to.
Find the workload identity with call_api WorkloadIdentityService/ListWorkloadIdentities on the project. Use one whose subject pattern names this repository. If there is none, create one with administer_workspace.
Call this tool. Write each file at its path, and on GitLab add the include line the result gives to .gitlab-ci.yml. Ask before you replace a file that exists. Open a pull request into the default branch.
The jobs sign in with their own ID token, so the repository needs no secret. The workflows run only when a file in the migration folder changes, so the setup pull request runs neither, and the first pull request with a migration file is the test. With the GitOps Service Agent role, the identity's rollouts carry no issue, so no approval rule holds them: tell the owner that merging deploys.
You may fit the files to the repository, for example the runner, the stages, or how they join an existing pipeline. Keep BYTEBASE_URL, BYTEBASE_WORKLOAD_IDENTITY, the job permissions, the ID token settings, the action image, --project, --targets and the order of the deploy jobs. The identity admits every job in the repository, so the triggers alone decide which branch deploys: tell the owner before a change that lets another branch deploy.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project": "<project>",
"targets": "<targets>",
"workloadIdentity": "<workloadIdentity>"
},
"name": "get_gitops_workflow"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder | No | ||
| project | Yes | ||
| targets | Yes | ||
| workloadIdentity | Yes |