|
1 | 1 | # dbt-docs-to-notion |
2 | | -A github action for exporting dbt docs to a notion database |
| 2 | +A Github action for exporting dbt model docs to a Notion database, where they can be conveniently consumed (especially by casual users in your org). |
| 3 | + |
| 4 | +## Output |
| 5 | +A Notion database, within a page of your choosing, with records like this: |
| 6 | + |
| 7 | + |
| 8 | +## Usage |
| 9 | +### Prerequisites |
| 10 | +In advance of using this action, you should: |
| 11 | +1. [Create a new integration within your Notion workspace](https://www.notion.so/my-integrations) |
| 12 | +2. Have your Notion integration token and a working dbt `profiles.yml` accessible to your repo (I'd recommend using [Github's repository secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets); see example workflow below). |
| 13 | +### Inputs |
| 14 | +- `dbt-package`: dbt-bigquery, dbt-postgres, dbt-bigquery==1.0.0, etc. (**required**) |
| 15 | +- `dbt-profile-path`: where profile.yml lives (default: `./`) |
| 16 | +- `dbt-target`: profile target to use for dbt docs generation (**required**) |
| 17 | +- `model-records-to-write`: "all" or "model_name_1 model_name_2 ..." (default: "all") |
| 18 | +- `notion-database-name`: what to name the Notion database of dbt models (**required**) |
| 19 | +- `notion-parent-id`: Notion page where database of dbt models will be added (**required**) |
| 20 | +- `notion-token`: Notion token API for integration to use (pass using secrets) (**required**) |
| 21 | + |
| 22 | +### Post-initialization Touchups |
| 23 | +Unfortunately, Notion's API doesn't allow for setting the order of properties or records in a database. Thus, after creating your database, you'll probably want to do some re-arranging (I'd recommend adding a table view to your database's parent page). |
| 24 | + |
| 25 | +### Example workflow |
| 26 | +``` |
| 27 | +name: dbt Docs to Notion |
| 28 | +
|
| 29 | +on: |
| 30 | + - pull_request |
| 31 | +
|
| 32 | +jobs: |
| 33 | + dbt-docs-to-notion: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v2 |
| 38 | + - name: Create temp dbt profiles |
| 39 | + run: "printf %s \"$DBT_PROFILES\" > ./profiles.yml" |
| 40 | + env: |
| 41 | + DBT_PROFILES: ${{ secrets.DBT_PROFILES }} |
| 42 | + - name: dbt-docs-to-notion |
| 43 | + uses: ./.github/actions/dbt-docs-to-notion |
| 44 | + with: |
| 45 | + dbt-package: 'dbt-bigquery==1.0.0' |
| 46 | + dbt-profile-path: './' |
| 47 | + dbt-target: 'github_actions' |
| 48 | + model-records-to-write: "all" |
| 49 | + notion-database-name: 'dbt Models' |
| 50 | + notion-parent-id: 'your-page-id-here' |
| 51 | + notion-token: '${{ secrets.DBT_DOCS_TO_NOTION_TOKEN }}' |
| 52 | +``` |
0 commit comments