Skip to content

Rename GCP buckets.png to gcs-bucket-files.png #9

Rename GCP buckets.png to gcs-bucket-files.png

Rename GCP buckets.png to gcs-bucket-files.png #9

Workflow file for this run

name: CD for dbt Models
on:
push:
branches:
- main
jobs:
deploy:
name: Deploy to Production
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
# Step 3: Upgrade pip and setuptools
- name: Upgrade pip and setuptools
run: |
python -m pip install --upgrade pip setuptools wheel
# Step 4: Set up virtual environment and install dependencies
- name: Set up Virtual Environment
run: |
python -m venv dbt_bigquery_venv
source dbt_bigquery_venv/bin/activate
pip install dbt-bigquery==1.8.3
pip install -r requirements.txt
# Step 5: Create gcp-key.json and profiles.yml
- name: Create GCP Key and profiles.yml
run: |
mkdir -p /home/runner/.dbt
# Write the Google credentials JSON file
cat <<EOF > /home/runner/.dbt/gcp-key.json
{
"type": "${{ secrets.GOOGLE_TYPE }}",
"project_id": "${{ secrets.GOOGLE_PROJECT_ID }}",
"private_key_id": "${{ secrets.GOOGLE_PRIVATE_KEY_ID }}",
"private_key": "${{ secrets.GOOGLE_PRIVATE_KEY }}",
"client_email": "${{ secrets.GOOGLE_CLIENT_EMAIL }}",
"client_id": "${{ secrets.GOOGLE_CLIENT_ID }}",
"auth_uri": "${{ secrets.GOOGLE_AUTH_URI }}",
"token_uri": "${{ secrets.GOOGLE_TOKEN_URI }}",
"auth_provider_x509_cert_url": "${{ secrets.GOOGLE_AUTH_PROVIDER_CERT_URL }}",
"client_x509_cert_url": "${{ secrets.GOOGLE_CLIENT_CERT_URL }}"
}
EOF
# Validate the JSON
python -m json.tool /home/runner/.dbt/gcp-key.json
# Dynamically generate profiles.yml
cat <<EOF > /home/runner/.dbt/profiles.yml
default:
outputs:
prod:
dataset: prod_healthcare_data
job_execution_timeout_seconds: 300
job_retries: 1
keyfile: /home/runner/.dbt/gcp-key.json
location: US
method: service-account
priority: interactive
project: root-matrix-457217-p5
threads: 4
type: bigquery
target: prod
EOF
# Step 6: Deploy to Production
- name: Deploy to Production
run: |
source dbt_bigquery_venv/bin/activate
dbt run --profiles-dir /home/runner/.dbt --target prod