Skip to content

Workflow file for this run

name: DBT ANSI-compliant CI/CD Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
lint-sql:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install sqlfluff
run: pip install sqlfluff
- name: Lint SQL files
run: sqlfluff lint models --dialect ansi
dbt-run:
needs: lint-sql
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12
env:
POSTGRES_DB: dbt
POSTGRES_USER: user
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dbt-postgres
run: pip install dbt-postgres
- name: Set up dbt profile
run: |
mkdir -p ~/.dbt
echo "config_version: 2" > ~/.dbt/profiles.yml
echo "crispy_dataprep:" >> ~/.dbt/profiles.yml
echo " target: dev" >> ~/.dbt/profiles.yml
echo " outputs:" >> ~/.dbt/profiles.yml
echo " dev:" >> ~/.dbt/profiles.yml
echo " type: postgres" >> ~/.dbt/profiles.yml
echo " threads: 1" >> ~/.dbt/profiles.yml
echo " host: localhost" >> ~/.dbt/profiles.yml
echo " port: 5432" >> ~/.dbt/profiles.yml
echo " user: user" >> ~/.dbt/profiles.yml
echo " pass: password" >> ~/.dbt/profiles.yml
echo " dbname: dbt" >> ~/.dbt/profiles.yml
echo " schema: public" >> ~/.dbt/profiles.yml
- name: Run dbt
run: dbt run --profiles-dir ~/.dbt