Skip to main content

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 _latest or _changelog).

๐Ÿ’  Environment Variablesโ€‹

VariableDescription
GCP_PROJECT_IDGCP Project ID (e.g., biddirect-2)


๐Ÿš€ Job: update-bigquery-table-schemaโ€‹

StepDescription
Checkout repositoryClones the repo.
Authenticate with GCPAuthenticates using a service account (ENV_BIGQUERY_ADMIN_SERVICE_ACCOUNT) stored in GitHub Secrets.
Set up Cloud SDKInstalls and sets up the Google Cloud SDK CLI.
Install dependenciesInstalls Node.js dependencies from the functions directory.
Update _latest schemaRuns bq update to apply the schema to the *_latest table.
Update _changelog schemaRuns 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 NameDescription
<ENV>_BIGQUERY_ADMIN_SERVICE_ACCOUNTService account key JSON for GCP auth.

โœ… Example Usageโ€‹

To run this workflow:

  1. Go to the Actions tab in your GitHub repository.
  2. Select the workflow <ENV> - [BigQuery] Deploy table schema.
  3. Enter the schema_name (e.g., accounts or accounts_serviceUnit).
  4. 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.