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.