Skip to content

Instantly share code, notes, and snippets.

@sungchun12
Last active May 29, 2025 15:21
Show Gist options
  • Save sungchun12/47a93424f4a617aed9846b8555388f09 to your computer and use it in GitHub Desktop.
Save sungchun12/47a93424f4a617aed9846b8555388f09 to your computer and use it in GitHub Desktop.
Tobiko Cloud CI/CD github actions configuration with oauth client
gateways:
tobiko_cloud: # this will use the config in tcloud.yaml for state_connection
scheduler: # TODO: add the connection info below into the Tobiko Cloud Connections Page with the service account json in plain text for this scheduler
type: cloud
default_catalog: sqlmesh-public-demo
connection: # This connection is used for automatic unit test generation, external model creation, and table diffing
type: bigquery
method: service-account-json
concurrent_tasks: 5
register_comments: true
keyfile_json: {{ env_var('GOOGLE_SQLMESH_CREDENTIALS') }}
project: sqlmesh-public-demo
# Uncomment the `default_target_environment` line to use the default target environment when running
# tcloud sqlmesh plan
# export USER=<your name>
# it will resolve to: tcloud sqlmesh plan dev_<your name>
# default_target_environment: dev_{{ env_var('USER','sung') }}
default_gateway: tobiko_cloud
project: repo_a
model_defaults:
dialect: bigquery
start: 2024-12-01
# cron: '@hourly'
# Uncomment this line to prevent plans being applied to prod during development
# allow_prod_deploy: {{ env_var('ALLOW_PROD_DEPLOY', 'false') }}
# Linting rules to enforce standards for your team
linter:
enabled: true
# error if ["ambiguousorinvalidcolumn", "invalidselectstarexpansion"] rules violated
rules: ["ambiguousorinvalidcolumn", "invalidselectstarexpansion"]
# warn_rules: ["noselectstar"]
# ignored_rules: ["noselectstar"]
# enables synchronized deployments to prod when a PR is merged
cicd_bot:
type: github
merge_method: squash
enable_deploy_command: false
skip_pr_backfill: false
auto_categorize_changes:
external: full
python: full
sql: full
seed: full
# Uncomment the following lines to enable auto mode for faster development
plan:
enable_preview: true
# no_diff: true
# use_finalized_state: true
# no_prompts: true
# auto_apply: true
# list of users that are allowed to approve PRs for synchronized deployments
# When a user clicks "approve" on a PR, the PR will be automatically deployed to the target environment and merged into the main branch
users:
- username: sung_sqlmesh_demo
github_username: sungchun12
roles:
- required_approver
- username: afzal_sqlmesh_demo
github_username: afzaljasani
roles:
- required_approver
projects:
prod:
url: https://cloud.tobikodata.com/sqlmesh/tobiko/public-demo/ # TODO: update for your url
gateway: tobiko_cloud # gateway name in config.yaml
extras: bigquery,lsp,github
pip_executable: uv pip
default_project: prod
name: Tobiko Cloud CI/CD Bot
run-name: 🧃 Tobiko Cloud CI/CD Bot 🧃
on:
pull_request:
types:
- synchronize
- opened
# Required if using comments to issue commands to the bot
issue_comment:
types:
- created
# Required if using required approvers to automate deployments
pull_request_review:
types:
- edited
- submitted
- dismissed
# The latest commit is the one that will be used to create the PR environment and deploy to production
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
sqlmesh:
name: SQLMesh Actions
runs-on: ubuntu-latest
permissions:
# Required to access code in PR
contents: write
# Required to post comments
issues: write
# Required to update check runs
checks: write
# Required to merge
pull-requests: write
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event.issue.pull_request && github.event.issue.number || github.event.pull_request.number }}/merge
- name: Install tcloud CLI + Dependencies
run: |
pip install tcloud
shell: bash
- name: Run tcloud CI/CD Bot
run: |
tcloud sqlmesh_cicd -p ${{ github.workspace }} github --token ${{ secrets.GITHUB_TOKEN }} run-all
env: # TODO: update your GitHub secrets to include TCLOUD_CLIENT_ID, TCLOUD_CLIENT_SECRET
TCLOUD_CLIENT_ID: ${{ secrets.TCLOUD_CLIENT_ID }}
TCLOUD_CLIENT_SECRET: ${{ secrets.TCLOUD_CLIENT_SECRET }}
TCLOUD_URL: https://cloud.tobikodata.com/sqlmesh/tobiko/public-demo/ # TODO:update with your unique URL
TCLOUD_GATEWAY: tobiko_cloud # TODO:update with your gateway name
TCLOUD_EXTRAS: bigquery,github # TODO:update for your query engines
@sungchun12
Copy link
Author

@sungchun12
Copy link
Author

sungchun12 commented May 12, 2025

Place this github action config in this path at the root of your repo: .github/workflows/

If your SQLMesh project is in a subdirectory, line 55 should look like this, replace custom_dir:

tcloud sqlmesh_cicd -p ${{ github.workspace }}/custom_dir github --token ${{ secrets.GITHUB_TOKEN }} run-all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment