Skip to content

Add workflow for deploying dbt docs with manual option #6

Add workflow for deploying dbt docs with manual option

Add workflow for deploying dbt docs with manual option #6

name: Generate and Deploy dbt Docs
on:
release:
types: [published] # Triggers when a release is published
push:
branches: [ update-docs-workflow ] # Test branch - remove after testing
workflow_dispatch: # Allows manual triggering
inputs:
environment:
description: 'Environment (production/staging)'
required: false
default: 'production'
type: choice
options:
- production
- staging
force_deploy:
description: 'Force deployment even on pre-release'
required: false
default: false
type: boolean
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false
env:
PYTHON_VERSION: '3.9'
####### Secrets #######
####### Snowflake
DBT_TUVA_SNOWFLAKE_ACCOUNT: ${{ secrets.DBT_TUVA_SNOWFLAKE_ACCOUNT }}
DBT_TUVA_CI_DATABASE: ${{ secrets.DBT_TUVA_CI_DATABASE }}
DBT_SNOWFLAKE_CI_PASSWORD: ${{ secrets.DBT_SNOWFLAKE_CI_PASSWORD }}
DBT_SNOWFLAKE_CI_ROLE: ${{ secrets.DBT_SNOWFLAKE_CI_ROLE }}
DBT_SNOWFLAKE_CI_SCHEMA: ${{ secrets.DBT_SNOWFLAKE_CI_SCHEMA }}
DBT_SNOWFLAKE_CI_USER: ${{ secrets.DBT_SNOWFLAKE_CI_USER }}
DBT_SNOWFLAKE_CI_WAREHOUSE: ${{ secrets.DBT_SNOWFLAKE_CI_WAREHOUSE }}
jobs:
generate-docs:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./integration_tests/docs_generate
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dbt-core and Snowflake adapter
run: |
python -m pip install --upgrade pip
pip install dbt-core==1.8.6 dbt-snowflake
- name: dbt-deps
run: dbt deps --profiles-dir ./profiles/snowflake
- name: dbt-debug
run: dbt debug --profiles-dir ./profiles/snowflake
- name: dbt-docs-generate
run: |
dbt docs generate --profiles-dir ./profiles/snowflake
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './integration_tests/docs_generate/target' # dbt generates docs in the target directory
deploy:
needs: generate-docs
runs-on: ubuntu-latest
environment:
name: ${{ github.event.release.prerelease && 'github-pages-staging' || 'github-pages' }}
url: ${{ steps.deployment.outputs.page_url }}
if: ${{ !github.event.release.prerelease || github.event.inputs.force_deploy == 'true' }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4