Skip to content

Commit 6aa9a52

Browse files
committed
docs: gitops doc
1 parent 2ea332c commit 6aa9a52

File tree

6 files changed

+134
-144
lines changed

6 files changed

+134
-144
lines changed

content/docs/_layout.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,7 @@ expand_section_list: ['Self-host']
139139

140140
### [Overview](/vcs-integration/overview)
141141

142-
### Simple GitOps
143-
144-
#### [Overview](/vcs-integration/simple/overview)
145-
146-
#### [Add Git Provider](/vcs-integration/add-git-provider)
147-
148-
#### [Add GitOps Connector in Project](/vcs-integration/add-gitops-connector)
149-
150-
#### [Create Migration Files](/vcs-integration/create-migration-files)
151-
152-
#### [Troubleshoot 🐞](/vcs-integration/troubleshoot)
153-
154-
### Custom GitOps
155-
156-
#### [Overview](/vcs-integration/custom/overview)
157-
158-
#### [Release](/vcs-integration/custom/release)
142+
### [Release](/vcs-integration/release)
159143

160144
## SQL Editor
161145

content/docs/change-database/change-workflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ There are 2 typical workflows employed by the team to deal with database schema
1414

1515
<HintBlock type="info">
1616

17-
Release is only used in [Custom GitOps workflow](/docs/vcs-integration/custom/overview/). Like a Docker image, a `release` is immutable after it is created.
17+
Release is only used in [Custom GitOps workflow](/docs/gitops/overview/). Like a Docker image, a `release` is immutable after it is created.
1818

1919
</HintBlock>
2020

content/docs/tutorials/github-release-cicd-workflow.md

Lines changed: 119 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ While this guide uses GitHub Actions, the same principles can be applied to othe
2020

2121
<HintBlock type="info">
2222

23-
This tutorial code repository is at [https://github.com/bytebase/bytebase-release-cicd-workflows-example](https://github.com/bytebase/bytebase-release-cicd-workflows-example)
23+
This tutorial code repository is at [https://github.com/bytebase/release-cicd-workflows-example
24+
25+
](https://github.com/bytebase/release-cicd-workflows-example
26+
27+
)
2428

2529
</HintBlock>
2630

@@ -39,27 +43,29 @@ This tutorial code repository is at [https://github.com/bytebase/bytebase-releas
3943

4044
If you have **Enterprise Plan**, you can create a **Custom Role** for the service account which require fewer permissions, and assign this role instead of DBA:
4145

42-
- plans.create
43-
- plans.get
44-
- plans.preview
45-
- releases.check
46-
- releases.create
47-
- releases.get
48-
- rollouts.create
49-
- rollouts.get
50-
- rollouts.list
51-
- sheets.create
52-
- sheets.get
53-
- taskRuns.create
54-
- planCheckRuns.list
55-
- planCheckRuns.run
46+
- plans.create
47+
- plans.get
48+
- plans.preview
49+
- releases.check
50+
- releases.create
51+
- releases.get
52+
- rollouts.create
53+
- rollouts.get
54+
- rollouts.list
55+
- sheets.create
56+
- sheets.get
57+
- taskRuns.create
58+
- planCheckRuns.list
59+
- planCheckRuns.run
5660

5761
## Step 3 - Fork the Example Repository and Configure Variables
5862

59-
1. Go to the [bytebase-release-cicd-workflows-example](https://github.com/bytebase/bytebase-release-cicd-workflows-example) repository and fork it. There are two workflows in this repository:
63+
1. Go to the [bytebase-release-cicd-workflows-example](https://github.com/bytebase/release-cicd-workflows-example
64+
65+
) repository and fork it. There are two workflows in this repository:
6066

61-
- `.github/workflows/bytebase-check-release.yml`: Check the release SQL syntax when there's a pull request.
62-
- `.github/workflows/bytebase-release-cicd.yml`: Create a release in Bytebase when there's a merge to the `main` branch.
67+
- `.github/workflows/bytebase-check-release.yml`: Check the release SQL syntax when there's a pull request.
68+
- `.github/workflows/bytebase-release-cicd.yml`: Create a release in Bytebase when there's a merge to the `main` branch.
6369

6470
1. Go into `.github/workflows/bytebase-release-cicd.yml` and `.github/workflows/bytebase-check-release.yml`. In the `env` section, replace the variable values with your own and commit the changes.
6571

@@ -75,8 +81,9 @@ If you have **Enterprise Plan**, you can create a **Custom Role** for the servic
7581
## Step 4 - Create the Release and Roll out
7682

7783
To create migration files to trigger release creation, the files have to match the following pattern:
78-
- A migration file should start with digits, which is also its version. e.g. `20250101001_create_table_ddl.sql`.
79-
- 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.
84+
85+
- A migration file should start with digits, which is also its version. e.g. `20250101001_create_table_ddl.sql`.
86+
- 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.
8087

8188
1. Within your forked repository, create the following migration files under `migrations` directory:
8289

@@ -99,118 +106,117 @@ To create migration files to trigger release creation, the files have to match t
99106

100107
1. Commit to a new branch and create a pull request, the `bytebase-check-release` workflow will be triggered.
101108

102-
![gh-sql-review-no-pass](/content/docs/tutorials/github-release-cicd-workflow/gh-sql-review-no-pass.webp)
109+
![gh-sql-review-no-pass](/content/docs/tutorials/github-release-cicd-workflow/gh-sql-review-no-pass.webp)
103110

104-
You got this SQL review is because by default, there is a SQL review configured on `Prod` environment in Bytebase.
111+
You got this SQL review is because by default, there is a SQL review configured on `Prod` environment in Bytebase.
105112

106-
![bb-sql-review](/content/docs/tutorials/github-release-cicd-workflow/bb-sql-review.webp)
113+
![bb-sql-review](/content/docs/tutorials/github-release-cicd-workflow/bb-sql-review.webp)
107114

108115
1. 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.
109116

110-
```sql
111-
CREATE TABLE t1(id INT PRIMARY KEY NOT NULL);
112-
```
117+
```sql
118+
CREATE TABLE t1(id INT PRIMARY KEY NOT NULL);
119+
```
120+
121+
```sql
122+
ALTER TABLE t1 RENAME TO "t1_del";
113123

114-
```sql
115-
ALTER TABLE t1 RENAME TO "t1_del";
124+
DROP TABLE "t1_del";
116125

117-
DROP TABLE "t1_del";
126+
CREATE TABLE t2(id INT PRIMARY KEY NOT NULL);
127+
```
118128

119-
CREATE TABLE t2(id INT PRIMARY KEY NOT NULL);
120-
```
121-
122-
![gh-sql-review-pass](/content/docs/tutorials/github-release-cicd-workflow/gh-sql-review-pass.webp)
129+
![gh-sql-review-pass](/content/docs/tutorials/github-release-cicd-workflow/gh-sql-review-pass.webp)
123130

124131
1. When the SQL review is passed, you can merge the pull request. The `bytebase-release-cicd` workflow will be triggered to create a **release** in Bytebase and then roll out automatically. Go to **Actions** tab, you can see the workflow run and pass.
125132

126-
![gh-cicd-release-pass](/content/docs/tutorials/github-release-cicd-workflow/gh-cicd-release-pass.webp)
133+
![gh-cicd-release-pass](/content/docs/tutorials/github-release-cicd-workflow/gh-cicd-release-pass.webp)
127134

128135
1. If you click the link in the **Create release** section, you can see the release is created in Bytebase.
129136

130-
![bb-release](/content/docs/tutorials/github-release-cicd-workflow/bb-release.webp)
137+
![bb-release](/content/docs/tutorials/github-release-cicd-workflow/bb-release.webp)
131138

132139
1. If you click the link in the **Rollout** section, you can see the rollout is applied to the databases.
133140

134-
![bb-rollout](/content/docs/tutorials/github-release-cicd-workflow/bb-rollout.webp)
141+
![bb-rollout](/content/docs/tutorials/github-release-cicd-workflow/bb-rollout.webp)
135142

136143
## Breakdown of the GitHub Action Workflow
137144

138145
1. Check out your repo and log in to Bytebase to gain the access token.
139146

140-
```yaml
141-
- name: Checkout
142-
uses: actions/checkout@v4
143-
- name: Login to Bytebase
144-
id: login
145-
uses: bytebase/login-action@main
146-
with:
147-
bytebase-url: ${{ env.BYTEBASE_URL }}
148-
service-key: ${{ env.BYTEBASE_SERVICE_ACCOUNT }}
149-
service-secret: ${{ secrets.BYTEBASE_PASSWORD }}
150-
151-
```
147+
```yaml
148+
- name: Checkout
149+
uses: actions/checkout@v4
150+
- name: Login to Bytebase
151+
id: login
152+
uses: bytebase/login-action@main
153+
with:
154+
bytebase-url: ${{ env.BYTEBASE_URL }}
155+
service-key: ${{ env.BYTEBASE_SERVICE_ACCOUNT }}
156+
service-secret: ${{ secrets.BYTEBASE_PASSWORD }}
157+
```
152158
153159
1. The **create_release** step scans the files matching the pattern and collects them into a bundle. Note that these files should also obey the naming scheme mentioned above.
154160
155-
The bundle is first sent to check. If the check passes, a release is then created on Bytebase.
156-
157-
```yaml
158-
- name: Create release
159-
id: create_release
160-
uses: bytebase/create-release-action@v1
161-
with:
162-
url: ${{ env.BYTEBASE_URL }}
163-
token: ${{ steps.login.outputs.token }}
164-
project: ${{ env.BYTEBASE_PROJECT }}
165-
file-pattern: ${{ env.FILE_PATTERN }}
166-
check-release: 'FAIL_ON_ERROR'
167-
targets: ${{ env.BYTEBASE_TARGETS }}
168-
validate-only: 'false'
169-
```
161+
The bundle is first sent to check. If the check passes, a release is then created on Bytebase.
162+
163+
```yaml
164+
- name: Create release
165+
id: create_release
166+
uses: bytebase/create-release-action@v1
167+
with:
168+
url: ${{ env.BYTEBASE_URL }}
169+
token: ${{ steps.login.outputs.token }}
170+
project: ${{ env.BYTEBASE_PROJECT }}
171+
file-pattern: ${{ env.FILE_PATTERN }}
172+
check-release: 'FAIL_ON_ERROR'
173+
targets: ${{ env.BYTEBASE_TARGETS }}
174+
validate-only: 'false'
175+
```
170176
171177
1. Create a rollout and wait for completion.
172178
173-
```yaml
174-
- name: Create plan
175-
id: create_plan
176-
uses: bytebase/create-plan-from-release-action@v1
177-
with:
178-
url: ${{ env.BYTEBASE_URL }}
179-
token: ${{ steps.login.outputs.token }}
180-
project: ${{ env.BYTEBASE_PROJECT }}
181-
release: ${{ steps.create_release.outputs.release }}
182-
targets: ${{ env.BYTEBASE_TARGETS }}
183-
# 'FAIL_ON_ERROR' will fail the action if plan checks report errors.
184-
# Use 'SKIP' to skip the check.
185-
# Use 'FAIL_ON_WARNING' to fail if plan checks report warning.
186-
check-plan: 'FAIL_ON_ERROR'
187-
validate-only: 'false'
188-
189-
- name: Rollout
190-
id: rollout
191-
uses: bytebase/rollout-action@v1
192-
with:
193-
url: ${{ env.BYTEBASE_URL }}
194-
token: ${{ steps.login.outputs.token }}
195-
plan: ${{ steps.create_plan.outputs.plan }}
196-
# set target-stage to exit after the stage completes
197-
# target-stage: 'Test Stage'
198-
```
199-
200-
These are the steps:
201-
202-
- create the plan from the release
203-
- check the plan
204-
- create the rollout
205-
- wait for the rollout to complete
206-
207-
In the **create_plan** step, you can set check-plan to FAIL_ON_ERROR to fail the action if plan checks report errors. Use SKIP to skip plan checks. Use FAIL_ON_WARNING to fail the action if plan checks report warning.
208-
209-
The rollout pipeline stages are created on demand in the **wait_rollout** step. You can use target-stage to early exit the step. When the target stage completes, it exits. If target-stage is not provided or not found, wait_rollout will wait until all stages complete. The target-stage is a stage title in the deployment config in the project setting.
179+
```yaml
180+
- name: Create plan
181+
id: create_plan
182+
uses: bytebase/create-plan-from-release-action@v1
183+
with:
184+
url: ${{ env.BYTEBASE_URL }}
185+
token: ${{ steps.login.outputs.token }}
186+
project: ${{ env.BYTEBASE_PROJECT }}
187+
release: ${{ steps.create_release.outputs.release }}
188+
targets: ${{ env.BYTEBASE_TARGETS }}
189+
# 'FAIL_ON_ERROR' will fail the action if plan checks report errors.
190+
# Use 'SKIP' to skip the check.
191+
# Use 'FAIL_ON_WARNING' to fail if plan checks report warning.
192+
check-plan: 'FAIL_ON_ERROR'
193+
validate-only: 'false'
194+
195+
- name: Rollout
196+
id: rollout
197+
uses: bytebase/rollout-action@v1
198+
with:
199+
url: ${{ env.BYTEBASE_URL }}
200+
token: ${{ steps.login.outputs.token }}
201+
plan: ${{ steps.create_plan.outputs.plan }}
202+
# set target-stage to exit after the stage completes
203+
# target-stage: 'Test Stage'
204+
```
205+
206+
These are the steps:
207+
208+
- create the plan from the release
209+
- check the plan
210+
- create the rollout
211+
- wait for the rollout to complete
212+
213+
In the **create_plan** step, you can set check-plan to FAIL_ON_ERROR to fail the action if plan checks report errors. Use SKIP to skip plan checks. Use FAIL_ON_WARNING to fail the action if plan checks report warning.
214+
215+
The rollout pipeline stages are created on demand in the **wait_rollout** step. You can use target-stage to early exit the step. When the target stage completes, it exits. If target-stage is not provided or not found, wait_rollout will wait until all stages complete. The target-stage is a stage title in the deployment config in the project setting.
210216

211217
1. You can also apply releases to databases on Bytebase UI. If you wish, you can set up an action to just create the release and manually roll out later.
212218

213-
![bb-manual-apply](/content/docs/tutorials/github-release-cicd-workflow/bb-manual-apply.webp)
219+
![bb-manual-apply](/content/docs/tutorials/github-release-cicd-workflow/bb-manual-apply.webp)
214220

215221
## Step 5 - Manual Rollout for Pro or Enterprise Plan
216222

@@ -222,41 +228,41 @@ If you have **Pro** or **Enterprise** plan, you can manually rollout the release
222228

223229
1. Go to the `.github/workflows/bytebase-release-cicd.yml` file, uncomment the last line and commit the changes.
224230

225-
```yaml
226-
target-stage: 'Test Stage'
227-
```
231+
```yaml
232+
target-stage: 'Test Stage'
233+
```
228234
229235
1. You can find the stage name in the **Deployment Config** under `Sample Project`.
230236

231-
![bb-deployment-config](/content/docs/tutorials/github-release-cicd-workflow/bb-deployment-config.webp)
237+
![bb-deployment-config](/content/docs/tutorials/github-release-cicd-workflow/bb-deployment-config.webp)
232238

233239
1. Create a new branch with this file, and create a pull request. Merge it to the `main` branch.
234240

235241
- 20250101003_create_table_t3_ddl.sql
236242

237-
```sql
238-
CREATE TABLE t3(id INT PRIMARY KEY NOT NULL);
239-
```
243+
```sql
244+
CREATE TABLE t3(id INT PRIMARY KEY NOT NULL);
245+
```
240246

241247
1. Go to the **Actions** tab, you can see the workflow run and pass. Expand the **Rollout** section, the rollout is created and the stage is skipped.
242248

243-
![gh-rollout-skip](/content/docs/tutorials/github-release-cicd-workflow/gh-rollout-skip.webp)
249+
![gh-rollout-skip](/content/docs/tutorials/github-release-cicd-workflow/gh-rollout-skip.webp)
244250

245251
1. Click the link in the **Rollout** section, you will go to the **Rollout Pipeline** in Bytebase.
246252

247-
![bb-manual-rollout](/content/docs/tutorials/github-release-cicd-workflow/bb-manual-rollout.webp)
253+
![bb-manual-rollout](/content/docs/tutorials/github-release-cicd-workflow/bb-manual-rollout.webp)
248254

249255
1. Click the arrow button, and click **Confirm**. The **Prod Stage** will be created.
250256

251-
![bb-confirm-add](/content/docs/tutorials/github-release-cicd-workflow/bb-confirm-add.webp)
257+
![bb-confirm-add](/content/docs/tutorials/github-release-cicd-workflow/bb-confirm-add.webp)
252258

253259
1. Click into the script and click **Run**. The script will be applied to the prod database.
254260

255-
![bb-prod-run](/content/docs/tutorials/github-release-cicd-workflow/bb-prod-run.webp)
261+
![bb-prod-run](/content/docs/tutorials/github-release-cicd-workflow/bb-prod-run.webp)
256262

257263
1. Go back to the **Rollout Pipeline** page, you can see the **Prod Stage** is completed.
258264

259-
![bb-rollout-done](/content/docs/tutorials/github-release-cicd-workflow/bb-rollout-done.webp)
265+
![bb-rollout-done](/content/docs/tutorials/github-release-cicd-workflow/bb-rollout-done.webp)
260266

261267
## Summary
262268

content/docs/vcs-integration/custom/overview.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

content/docs/vcs-integration/overview.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ title: GitOps
44

55
Bytebase offers a database-as-code workflow, enabling you to manage database changes directly through your version control system (VCS).
66

7-
Bytebase provides two GitOps workflows:
7+
Bytebase GitOps workflow is built upon the [Bytebase API](/docs/api/overview). It provides the ultimate flexibility to customize the GitOps workflow to integrate with your CI/CD pipeline.
88

9-
- [Simple GitOps](/docs/vcs-integration/simple/overview): Opinionated and restricted for the simple use case.
10-
- [Custom GitOps](/docs/vcs-integration/custom/overview): Fully customizable via the Bytebase API.
9+
## GitHub
1110

12-
<HintBlock type="info">
11+
- Pre-built GitHub Actions: https://github.com/marketplace?query=bytebase&type=actions
12+
- Examples: https://github.com/bytebase/release-cicd-workflows-example
13+
- Tutorial: [Database Release CI/CD with GitHub Action](/docs/tutorials/github-release-cicd-workflow/)
1314

14-
If you manage database changes for multiple teams or have any branching strategy beyond the most basic, you will be likely need the [Custom GitOps](/docs/vcs-integration/custom/overview) workflow.
15+
## Other VCSs
1516

16-
</HintBlock>
17+
For other VCSs, we provide API integrations examples to help you get started.
18+
19+
- For other VCSs, we provide API integrations examples to help you get started.
20+
21+
## Legacy GitOps
22+
23+
Besides the API-driven GitOps, Bytebase also provides a [legacy GitOps workflow](/docs/vcs-integration/simple/overview/) based on the VCS webhooks. This approach is only kept for backward compatibility and we will sunset it in the future release.
File renamed without changes.

0 commit comments

Comments
 (0)