Skip to content

Commit 9fd1027

Browse files
committed
Support DBT custom --project-dir parameter
1 parent 6f49838 commit 9fd1027

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Ideally you should also write descriptions for models and columns as is a [best
2525

2626
- `dbt-package`: dbt-bigquery, dbt-postgres, dbt-bigquery==1.0.0, etc. (**required**)
2727
- `dbt-profile-path`: where profile.yml lives (default: `./`)
28+
- `dbt-project-path`: where dbt_project.yml lives (default: `./`)
2829
- `dbt-target`: profile target to use for dbt docs generation (**required**)
2930
- `model-records-to-write`: "all" or "model_name_1 model_name_2 ..." (default: "all")
3031
- `notion-database-name`: what to name the Notion database of dbt models (**required**)

action.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ inputs:
1111
description: 'where profile.yml lives'
1212
required: false
1313
default: './'
14+
dbt-project-path:
15+
description: 'where dbt_project.yml lives'
16+
required: false
17+
default: './'
1418
dbt-target:
1519
description: 'profile target to use for dbt docs generation'
1620
required: true
@@ -38,13 +42,13 @@ runs:
3842
run: "pip3 install ${{ inputs.dbt-package }}"
3943
shell: bash
4044
- name: Load dbt deps
41-
run: "dbt deps --profiles-dir ${{ inputs.dbt-profile-path }} --target=${{ inputs.dbt-target }}"
45+
run: "dbt deps --project-dir ${{ inputs.dbt-project-path }} --profiles-dir ${{ inputs.dbt-profile-path }} --target=${{ inputs.dbt-target }}"
4246
shell: bash
4347
- name: Generate dbt Docs
44-
run: "dbt docs generate --profiles-dir ${{ inputs.dbt-profile-path }} --target=${{ inputs.dbt-target }}"
48+
run: "dbt docs generate --project-dir ${{ inputs.dbt-project-path }} --profiles-dir ${{ inputs.dbt-profile-path }} --target=${{ inputs.dbt-target }}"
4549
shell: bash
4650
- name: Export dbt Docs to Notion
47-
run: "python3 ${{ github.action_path }}/dbt_docs_to_notion.py ${{ inputs.model-records-to-write }}"
51+
run: "python3 ${{ github.action_path }}/dbt_docs_to_notion.py ${{ inputs.dbt-project-path }} ${{ inputs.model-records-to-write }}"
4852
shell: bash
4953
env:
5054
DATABASE_NAME: ${{ inputs.notion-database-name }}

dbt_docs_to_notion.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,16 @@ def get_owner(data, catalog_nodes, model_name):
6161
def main(argv=None):
6262
if argv is None:
6363
argv = sys.argv
64-
model_records_to_write = argv[1:] # 'all' or list of model names
64+
dbt_project_dir = argv[1]
65+
model_records_to_write = argv[2:] # 'all' or list of model names
6566
print(f'Model records to write: {model_records_to_write}')
6667

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

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

0 commit comments

Comments
 (0)