🚀SQLMesh Bot 🚀 #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SQLMesh Bot | |
run-name: 🚀SQLMesh Bot 🚀 | |
on: | |
pull_request: | |
types: | |
- synchronize | |
- opened | |
# GitHub secrets | |
env: | |
#DBT_PROFILES_DIR: ./dbt_project | |
GITHUB_SHA_OVERRIDE: ${{ github.event.pull_request.head.sha }} # We need the commit hash of the pull request branch's head, the GITHUB_SHA env var is always the base branch in a pull_request_target trigger | |
DBT_ENV_SECRET_BIGQUERY_TEST_SERVICE_ACCOUNT: ${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_SERVICE_ACCOUNT }} | |
DBT_ENV_SECRET_BIGQUERY_TEST_STORAGE_PROJECT: ${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_STORAGE_PROJECT }} | |
DBT_ENV_SECRET_BIGQUERY_TEST_EXECUTION_PROJECT: ${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_EXECUTION_PROJECT }} | |
DBT_ENV_SECRET_BIGQUERY_TEST_LOCATION: ${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_LOCATION }} | |
GOOGLE_APPLICATION_CREDENTIALS: "./keyfile.json" | |
# 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 Workflow | |
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: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Write keyfile if secret is defined | |
run: | | |
if [ -z "${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_SERVICE_ACCOUNT }}" ]; then | |
echo "Error: DBT_ENV_SECRET_BIGQUERY_TEST_SERVICE_ACCOUNT is not defined." | |
else | |
echo ${{ secrets.DBT_ENV_SECRET_BIGQUERY_TEST_SERVICE_ACCOUNT }} | base64 -d > keyfile.json | |
fi | |
- 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 SQLMesh + Dependencies | |
run: pip install -r requirements.txt | |
shell: bash | |
- name: Check dbt debug | |
run: | | |
cd dbt_project && pwd && dbt debug | |
- name: Run CI/CD Bot | |
run: | | |
cd ${{ github.workspace }} && pwd && sqlmesh_cicd -p ${{ github.workspace }}/dbt_project -p ${{ github.workspace }}/sqlmesh_project github --token ${{ secrets.GITHUB_TOKEN }} run-all |