deploy-dbt-docs #447
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: deploy-dbt-docs | |
on: | |
workflow_run: | |
workflows: [build-and-test-dbt] | |
branches: [master] | |
types: [completed] | |
workflow_dispatch: | |
jobs: | |
deploy-dbt-docs: | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
# These permissions are required to make a GitHub Pages deployment | |
permissions: | |
pages: write # To deploy to Pages | |
id-token: write # To verify the deployment comes from an valid source | |
if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup dbt | |
uses: ./.github/actions/setup_dbt | |
with: | |
role-to-assume: ${{ secrets.AWS_IAM_ROLE_TO_ASSUME_ARN }} | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
- name: Install docs build dependencies | |
run: npm install -g @mermaid-js/mermaid-cli | |
- name: Prepare Mermaid assets for docs | |
run: | | |
for file in assets/*.mmd; do | |
# Confine the mermaid process to an AppArmor profile, necessary on | |
# Ubuntu >= 23.10 to work around new AppArmor rules that block the | |
# Puppeteer sandbox (used by mermaid) from working. See: | |
# https://github.com/mermaid-js/mermaid-cli/issues/730#issuecomment-2408615110 | |
aa-exec --profile=chrome mmdc -i "$file" -o "${file/.mmd/.svg}" | |
done | |
working-directory: ${{ env.PROJECT_DIR }} | |
shell: bash | |
- name: Generate docs | |
run: | | |
dbt docs generate --target prod | |
# Editing index.html to inject a custom stylesheet and change the site metadata | |
sed -i 's|</head>|\t<link rel="stylesheet" href="./assets/ccao-style.css" />\n</head>|' target/index.html | |
sed -i 's|</head>|\t<script defer src="./assets/ccao-script.js"></script>\n</head>|' target/index.html | |
sed -i 's|<title>dbt Docs</title>|<title>CCAO Data Catalog</title>|' target/index.html | |
sed -i 's|content="dbt Docs"|content="CCAO Data Catalog"|' target/index.html | |
sed -i 's|content="documentation for dbt"|content="Cook County Assessor'\''s Office data documentation"|' target/index.html | |
working-directory: ${{ env.PROJECT_DIR }} | |
shell: bash | |
- name: Package doc files for upload | |
run: | | |
mkdir -p _site/assets | |
for file in index.html catalog.json manifest.json; do | |
cp "target/$file" "_site/$file" | |
done | |
cp -R target/assets/* _site/assets | |
working-directory: ${{ env.PROJECT_DIR }} | |
shell: bash | |
- name: Upload docs directory artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ${{ format('{0}/_site', env.PROJECT_DIR) }} | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |