Deploy Table Schema
π <ENV> - [BigQuery] Deploy table schemaβ
This GitHub Actions workflow is designed to manually deploy or update BigQuery table schemas based on a JSON schema file. It uses bq CLI commands to apply the schema to both the _latest and _changelog versions of a BigQuery table.
π Workflow Triggerβ
This workflow is triggered manually from github actions in functions repo
Required Input:β
schema_name(string): The base name of the schema (without suffixes like_latestor_changelog).
π Environment Variablesβ
| Variable | Description |
|---|---|
GCP_PROJECT_ID | GCP Project ID (e.g., biddirect-2) |
π Job: update-bigquery-table-schemaβ
| Step | Description |
|---|---|
| Checkout repository | Clones the repo. |
| Authenticate with GCP | Authenticates using a service account (ENV_BIGQUERY_ADMIN_SERVICE_ACCOUNT) stored in GitHub Secrets. |
| Set up Cloud SDK | Installs and sets up the Google Cloud SDK CLI. |
| Install dependencies | Installs Node.js dependencies from the functions directory. |
Update _latest schema | Runs bq update to apply the schema to the *_latest table. |
Update _changelog schema | Runs bq update to apply the schema to the *_changelog table. |
π§Ή Schema File Locationβ
Schema JSON files should be placed under:
functions/src/bqDataLake/definitions/tableSchemas/
Each file should follow the naming convention:
<schema_name>.json
Example:
functions/src/bqDataLake/definitions/tableSchemas/accounts.json
π Required Secretsβ
| Secret Name | Description |
|---|---|
<ENV>_BIGQUERY_ADMIN_SERVICE_ACCOUNT | Service account key JSON for GCP auth. |
β Example Usageβ
To run this workflow:
- Go to the Actions tab in your GitHub repository.
- Select the workflow
<ENV> - [BigQuery] Deploy table schema. - Enter the
schema_name(e.g.,accountsoraccounts_serviceUnit). - Click "Run workflow".
This will update the following BigQuery tables in bqDataLake:
<schema_name>_latest<schema_name>_changelog
Both tables will be updated with the new schema definition.