Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Ideally you should also write descriptions for models and columns as is a [best

- `dbt-package`: dbt-bigquery, dbt-postgres, dbt-bigquery==1.0.0, etc. (**required**)
- `dbt-profile-path`: where profile.yml lives (default: `./`)
- `dbt-project-path`: where dbt_project.yml lives (default: `./`)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind adding under ### Example workflow also?

- `dbt-target`: profile target to use for dbt docs generation (**required**)
- `model-records-to-write`: "all" or "model_name_1 model_name_2 ..." (default: "all")
- `notion-database-name`: what to name the Notion database of dbt models (**required**)
Expand Down
10 changes: 7 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
description: 'where profile.yml lives'
required: false
default: './'
dbt-project-path:
description: 'where dbt_project.yml lives'
required: false
default: './'
dbt-target:
description: 'profile target to use for dbt docs generation'
required: true
Expand Down Expand Up @@ -38,13 +42,13 @@ runs:
run: "pip3 install ${{ inputs.dbt-package }}"
shell: bash
- name: Load dbt deps
run: "dbt deps --profiles-dir ${{ inputs.dbt-profile-path }} --target=${{ inputs.dbt-target }}"
run: "dbt deps --project-dir ${{ inputs.dbt-project-path }} --profiles-dir ${{ inputs.dbt-profile-path }} --target=${{ inputs.dbt-target }}"
shell: bash
- name: Generate dbt Docs
run: "dbt docs generate --profiles-dir ${{ inputs.dbt-profile-path }} --target=${{ inputs.dbt-target }}"
run: "dbt docs generate --project-dir ${{ inputs.dbt-project-path }} --profiles-dir ${{ inputs.dbt-profile-path }} --target=${{ inputs.dbt-target }}"
shell: bash
- name: Export dbt Docs to Notion
run: "python3 ${{ github.action_path }}/dbt_docs_to_notion.py ${{ inputs.model-records-to-write }}"
run: "python3 ${{ github.action_path }}/dbt_docs_to_notion.py ${{ inputs.dbt-project-path }} ${{ inputs.model-records-to-write }}"
shell: bash
env:
DATABASE_NAME: ${{ inputs.notion-database-name }}
Expand Down
7 changes: 4 additions & 3 deletions dbt_docs_to_notion.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ def get_owner(data, catalog_nodes, model_name):
def main(argv=None):
if argv is None:
argv = sys.argv
model_records_to_write = argv[1:] # 'all' or list of model names
dbt_project_dir = argv[1]
model_records_to_write = argv[2:] # 'all' or list of model names
print(f'Model records to write: {model_records_to_write}')

###### load nodes from dbt docs ######
with open('target/manifest.json', encoding='utf-8') as f:
with open(f'{dbt_project_dir}/target/manifest.json', encoding='utf-8') as f:
manifest = json.load(f)
manifest_nodes = manifest['nodes']

with open('target/catalog.json', encoding='utf-8') as f:
with open(f'{dbt_project_dir}/target/catalog.json', encoding='utf-8') as f:
catalog = json.load(f)
catalog_nodes = catalog['nodes']

Expand Down