Learn how to automate semantic type and global masking rule using GitHub Actions and Bytebase API
localhost:8080
.
<<YOURS>>.ngrok-free.app
.
https://<<YOURS>>.ngrok-free.app
.
https://<<YOURS>>.ngrok-free.app
as the External URL and click Confirm and update.
Workspace Admin
, and go to IAM & Admin > Users & Groups. Click + Add User, fill in with api-sample
, choose the Workspace DBA
role sufficient for this tutorial and click Confirm.
Sample Project
with two database hr_test
and hr_prod
.dev@example.com
, dev2@example.com
and dev3@example.com
with no roles.contractor@example.com
with dev3@example.com
as a member.Sample Project
, click Manage > Members on the left sidebar.dev@example.com
and dev2@example.com
with Developer
role and group contractor@example.com
with Querier
role.BYTEBASE_URL
: ngrok external URLBYTEBASE_SERVICE_KEY
: api-example@service.bytebase.com
BYTEBASE_SERVICE_SECRET
: service key copied in the previous stepmain
.
Login Bytebase
will log in Bytebase using the official bytebase-login action. The variables you configured in the GitHub Secrets and variables are mapped to the variables in the action.
Get changed files
will monitor the changed files in the pull request. For this workflow, we only care about semantic type and global masking rule. So masking/semantic-type.json
and masking/global-masking-rule.json
are filtered out.
Comment on PR
will comment on the merged pull to notify the result.
birth_date
with a masking algorithm to mask month and day.
Apply semantic type
, which will apply the semantic type to the database via API. All the masking algorithms should be defined in one file in the root directory as masking/semantic-type.json
.
masking/semantic-type.json
, creating a PR and merging, the semantic types will be applied. Go to Bytebase console, click Data Access > Semantic Types, you can see the applied semantic types.
Apply global masking rule
, which will apply the global masking rule to the database via API. All the global masking rules should be defined in one file in the root directory as masking/global-masking-rule.json
. The code it calls Bytebase API is as follows:
masking/global-masking-rule.json
, creating a PR and merge, you can apply the global masking rules.