diff --git a/README.md b/README.md index 4d38748..2572f5f 100644 --- a/README.md +++ b/README.md @@ -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: `./`) - `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**) diff --git a/action.yml b/action.yml index 20d050e..25045cd 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 }} diff --git a/dbt_docs_to_notion.py b/dbt_docs_to_notion.py index 6213b86..856f7c2 100644 --- a/dbt_docs_to_notion.py +++ b/dbt_docs_to_notion.py @@ -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']