You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mintlify/tutorials/gitops-github-workflow.mdx
+75-2Lines changed: 75 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,8 @@ This tutorial shows you how to build an database GitOps workflow using GitHub Ac
32
32
33
33
2. Manually control rollouts by stage
34
34
35
+
3. Deploy changes via ChatOps-style PR comments
36
+
35
37
<Info>
36
38
37
39
While we use PostgreSQL with GitHub Actions in this guide, you can apply these concepts to other SQL or NoSQL databases with any CI platforms like GitLab CI, Bitbucket Pipelines, or Azure DevOps using the Bytebase API.
### Step 4 - Fork the Example Repository and Configure Variables
65
67
66
-
1. Fork [https://github.com/bytebase/example-gitops-github-flow](https://github.com/bytebase/example-gitops-github-flow). There are two workflows in this repository:
68
+
1. Fork [https://github.com/bytebase/example-gitops-github-flow](https://github.com/bytebase/example-gitops-github-flow). There are three workflows in this repository:
67
69
68
70
-`.github/workflows/sql-review-action.yml`: [Lint the SQL](/sql-review/review-policy/) migration files after the PR is created.
69
71
-`.github/workflows/release-action.yml`: Create a release in Bytebase after the PR is merged to the `main` branch.
72
+
-`.github/workflows/chatops-migrate.yml`: Deploy changes to specific environments via PR comments using `/migrate` command.
70
73
71
74
1. Go into `.github/workflows/release-action.yml` and `.github/workflows/sql-review-action.yml`. In the `env` section, replace the variable values with your own and commit the changes.
72
75
@@ -165,6 +168,76 @@ You can also manually control the rollout by stage.
In addition to automatic and manual deployments, you can also deploy database changes to any environment directly from pull request comments using ChatOps commands.
174
+
175
+
Team members can trigger deployments by commenting `/migrate <environment>` on any pull request. The workflow will:
176
+
1. Validate the command and environment
177
+
2. Create a rollout plan in Bytebase
178
+
3. Execute the migration to the specified environment
179
+
4. Report the results back in the PR comments
180
+
181
+
### Step 1 - Configure ChatOps Workflow
182
+
183
+
1. Go into `.github/workflows/chatops-migrate.yml`. In the `env` section, replace the variable values with your own:
3. Set your service account password in the repository secrets setting with the name `BYTEBASE_SERVICE_ACCOUNT_SECRET`.
208
+
209
+
4. In **Settings > Environments**, ensure you have environments matching your config (e.g., "test", "prod"). For production, configure deployment protection rules if needed.
210
+
211
+
### Step 2 - Deploy via PR Comments
212
+
213
+
1. Create a new branch with this file and create a pull request:
214
+
215
+
- 1.14.0_code.sql
216
+
217
+
```sql
218
+
ALTER TABLE IF EXISTS users ADD COLUMN IF NOT EXISTS code VARCHAR(255) NOT NULL DEFAULT '';
219
+
```
220
+
221
+
2. After the SQL review passes, comment `/migrate test` on the PR to deploy to test environment.
5. To deploy to production, comment `/migrate prod`. If production requires approval, the workflow will wait for reviewers.
234
+
168
235
## Summary
169
236
170
-
Now you have learned how to database GitOps with GitHub Action. If you want to trigger a release creation with other git providers (e.g. GitLab, Bitbucket, Azure DevOps), you may customize the workflow file.
237
+
Now you have learned how to implement database GitOps with GitHub Actions in three ways:
238
+
239
+
1. **Automatic deployment** after merging to main branch
240
+
2. **Manual rollout** with environment-level approval
241
+
3. **ChatOps deployment** via PR comments for pre-merge testing
242
+
243
+
If you want to trigger a release creation with other git providers (e.g. GitLab, Bitbucket, Azure DevOps), you may customize the workflow file.
0 commit comments