Skip to content

Instantly share code, notes, and snippets.

@matsonj
Last active January 30, 2024 17:35
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matsonj/bb3b54642a8d3ec0377be8a903c16165 to your computer and use it in GitHub Desktop.
Save matsonj/bb3b54642a8d3ec0377be8a903c16165 to your computer and use it in GitHub Desktop.
Running dbt-core with github actions
name: pr_to_master
on:
pull_request:
branches:
- master
env:
DBT_PROFILES_DIR: ./
MSSQL_USER: ${{ secrets.MSSQL_USER }}
MSSQL_PROD: ${{ secrets.MSSQL_PROD }}
MSSQL_LOGIN: ${{ secrets.MSSQL_LOGIN }}
# note: you can also run dbt from inside a github action with a github cloud action runner.
# in that case, you will have to add steps to your job to choose the right docker image as
# well as pip install dbt. make sure to set your pins as well.
jobs:
pr_to_master:
name: pr_to_master
runs-on: self-hosted
steps:
- name: Check out
uses: actions/checkout@master
- name: Get dependencies
run: dbt deps --target prod
- name: Run dbt build
run: dbt build --target prod
default: #
target: dev
outputs:
dev:
type: sqlserver
driver: 'ODBC Driver 17 for SQL Server'
server: "{{ env_var('MSSQL_DEV') }}"
port: 1433
schema: dbo
user: "{{ env_var('MSSQL_USER') }}"
password: "{{ env_var('MSSQL_LOGIN') }}"
database: Operations
threads: 4
prod:
type: sqlserver
driver: 'ODBC Driver 17 for SQL Server'
server: "{{ env_var('MSSQL_PROD') }}"
port: 1433
schema: dbo
user: "{{ env_var('MSSQL_USER') }}"
password: "{{ env_var('MSSQL_LOGIN') }}"
database: Operations
threads: 4
name: run_from_github
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
name:
# Friendly description to be shown in the UI instead of 'name'
description: 'What is the reason to trigger this manually?'
# Default value if no value is explicitly provided
default: 'workflow test'
# Input has to be provided for the workflow to run
required: true
env:
DBT_PROFILES_DIR: ./
MSSQL_USER: ${{ secrets.MSSQL_USER }}
MSSQL_PROD: ${{ secrets.MSSQL_PROD }}
MSSQL_LOGIN: ${{ secrets.MSSQL_LOGIN }}
jobs:
run_from_github:
name: run_from_github
runs-on: self-hosted
steps:
- name: Check out
uses: actions/checkout@master
- name: Get dependencies # ok guess I need this anyway
run: dbt deps --target prod
- name: Run dbt build
run: dbt build --target prod
name: scheduled_run
on:
schedule:
- cron: '0 13 * * *'
env:
DBT_PROFILES_DIR: ./
MSSQL_USER: ${{ secrets.MSSQL_USER }}
MSSQL_PROD: ${{ secrets.MSSQL_PROD }}
MSSQL_LOGIN: ${{ secrets.MSSQL_LOGIN }}
jobs:
scheduled_run:
name: scheduled_run
runs-on: self-hosted
steps:
- name: Check out
uses: actions/checkout@master
- name: Get dependencies # ok guess I need this anyway
run: dbt deps --target prod
- name: Run dbt build
run: dbt build --target prod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment