Skip to content

Commit b562b48

Browse files
authored
chore: update readme (#20)
1 parent a666949 commit b562b48

File tree

1 file changed

+60
-4
lines changed

1 file changed

+60
-4
lines changed

README.md

+60-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,67 @@ This repository demonstrates how to use Bytebase and GitHub actions to do databa
44

55
For GitHub flow, feature branches are merged into the main branch and the main branch is deployed to the, for example, "test" and "prod" environments in a deploy pipeline.
66

7-
[sql-review.yml](/.github/workflows/sql-review.yml) checks the SQL migration files against the databases when pull requests are created.
7+
[sql-review-action.yml](/.github/workflows/sql-review-action.yml) checks the SQL migration files against the databases when pull requests are created.
88

9-
[release.yml](/.github/workflows/release.yml) builds the code and then for each environment migrate the databases and deploy the code. Using [environments with protection rules](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-deployments/managing-environments-for-deployment#required-reviewers), it can deploy to the test environment automatically and push to the prod environment after approval.
9+
[release-action.yml](/.github/workflows/release-action.yml) builds the code and then for each environment migrate the databases and deploy the code. Using [environments with protection rules](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-deployments/managing-environments-for-deployment#required-reviewers), it can deploy to the test environment automatically and push to the prod environment after approval.
1010

11-
## How to configure sql-review.yml
11+
## Use bytebase/bytebase-action (recommended)
12+
13+
The README of bytebase/bytebase-action can be found at [README](https://github.com/bytebase/bytebase/blob/main/action/README.md).
14+
15+
### How to configure sql-review-action.yml
16+
17+
Copy [sql-review-action.yml](/.github/workflows/sql-review-action.yml) to your repository.
18+
19+
Modify the environment variables to match your setup.
20+
21+
```yml
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # set GITHUB_TOKEN because the 'Check release' step needs it to comment the pull request with check results.
24+
BYTEBASE_URL: https://demo.bytebase.com
25+
BYTEBASE_SERVICE_ACCOUNT: [email protected]
26+
BYTEBASE_SERVICE_ACCOUNT_SECRET: ${{secrets.BYTEBASE_SERVICE_ACCOUNT_SECRET}}
27+
BYTEBASE_PROJECT: "projects/project-sample"
28+
BYTEBASE_TARGETS: "instances/test-sample-instance/databases/hr_test" # the database targets to check against.
29+
FILE_PATTERN: "migrations/*.sql" # the glob pattern matching the migration files.
30+
```
31+
32+
Set your service account password in the repository secrets setting with the name `BYTEBASE_SERVICE_ACCOUNT_SECRET`.
33+
34+
> [!IMPORTANT]
35+
> The migration filename SHOULD comply to the naming scheme described in [bytebase/create-release-action](https://github.com/bytebase/create-release-action/tree/main).
36+
37+
### How to configure release-action.yml
38+
39+
Copy [release-action.yml](/.github/workflows/release-action.yml) to your repository.
40+
41+
Modify the environment variables to match your setup.
42+
You need to edit both deploy-to-test and deploy-to-prod jobs.
43+
44+
```yml
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
BYTEBASE_URL: https://demo.bytebase.com
48+
BYTEBASE_SERVICE_ACCOUNT: [email protected]
49+
BYTEBASE_SERVICE_ACCOUNT_SECRET: ${{secrets.BYTEBASE_SERVICE_ACCOUNT_SECRET}}
50+
BYTEBASE_PROJECT: "projects/project-sample"
51+
# The Bytebase rollout pipeline will deploy to 'test' and 'prod' environments.
52+
# 'deploy_to_test' job rollouts the 'test' stage and 'deploy_to_prod' job rollouts the 'prod' stage.
53+
BYTEBASE_TARGETS: "instances/test-sample-instance/databases/hr_test,instances/prod-sample-instance/databases/hr_prod"
54+
BYTEBASE_TARGET_STAGE: environments/test
55+
FILE_PATTERN: "migrations/*.sql"
56+
```
57+
58+
In the repository environments setting, create two environments: "test" and "prod". In the "prod" environment setting, configure "Deployment protection rules", check "Required reviewers" and add reviewers in order to rollout the "prod" environment after approval.
59+
60+
Set your service account password in the repository secrets setting with the name `BYTEBASE_SERVICE_ACCOUNT_SECRET`.
61+
62+
> [!IMPORTANT]
63+
> The migration filename SHOULD comply to the naming scheme described in [bytebase/create-release-action](https://github.com/bytebase/create-release-action/tree/main).
64+
65+
## Use javascript actions
66+
67+
### How to configure sql-review.yml
1268

1369
Copy [sql-review.yml](/.github/workflows/sql-review.yml) to your repository.
1470

@@ -29,7 +85,7 @@ Set your service account password in the repository secrets setting with the nam
2985
> [!IMPORTANT]
3086
> The migration filename SHOULD comply to the naming scheme described in [bytebase/create-release-action](https://github.com/bytebase/create-release-action/tree/main).
3187

32-
## How to configure release.yml
88+
### How to configure release.yml
3389

3490
Copy [release.yml](/.github/workflows/release.yml) to your repository.
3591

0 commit comments

Comments
 (0)