Export And Commit Table Schemas
๐ <ENV> - [BigQuery] Export and Commit Table Schemasโ
This GitHub Actions workflow automates the extraction of BigQuery table schemas from the bqDataLake dataset and commits them to the repository. It helps ensure that your schema definitions remain version-controlled and in sync with BigQuery.
๐ Workflow Triggerโ
This workflow is triggered manually via the GitHub actions in function repo.
๐ Environment Variablesโ
| Variable | Description |
|---|---|
GCP_PROJECT_ID | GCP Project ID (e.g., biddirect-2) |
DATASET_ID | BigQuery dataset ID (e.g., bqDataLake) |
๐งฑ๏ธ Workflow Job: export-and-commit-bigquery-schemasโ
| Step | Description |
|---|---|
| Checkout repository | Clones the GitHub repository to the runner. |
| Authenticate with GCP | Authenticates using a service account (<ENV>_BIGQUERY_ADMIN_SERVICE_ACCOUNT) stored in GitHub Secrets. |
| Set up Cloud SDK | Installs and configures the Google Cloud SDK CLI. |
| Create output directory | Creates the directory to store schema JSON files. |
| Get all schemas from BigQuery | Iterates over all tables in the dataset (excluding _changelog and non-table types), exports schema definitions, and saves them to local files. |
| Commit and Push Schema Files | Stages and commits any updated schema files to the repository. |
๐งน Export Logic Summaryโ
-
Skips tables ending with
_changelog -
Skips views or other non-
TABLEresources -
Removes
_latestsuffix from table names when naming schema files -
Stores output in:
functions/src/bqDataLake/definitions/tableSchemas/
Example:
Table: accounts_latest โ File: 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] Export and Commit Table Schemas. - Click "Run workflow".
This will:
- Export schemas for all physical
_latesttables in thebqDataLakedataset - Save each schema in JSON format to the repo
- Automatically commit and push the updated files to the branch from which the workflow was executed
This workflow ensures that schema changes are tracked alongside application code.