diff --git a/README.md b/README.md index 557df1c..0fdb911 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ steps: databricks-token: token local-path: ./my-local-path remote-path: /my-remote-path + # clean-workspace-remote-directory: true ``` ### Inputs @@ -42,6 +43,7 @@ steps: | `databricks-token` | Databricks token, it can be a PAT or an AAD Token | true |NA| | `local-path` | Path of the directory you want to import | true |NA| | `remote-path` | Path of the directory inside Databricks workspace where you want the files to land| true |NA| +| `clean-workspace-remote-directory` | Removes objects recursive from the Databricks workspace specified remote-path before they get added by this action| false | false | ## Contributing diff --git a/action.yml b/action.yml index 7828490..24bdb70 100644 --- a/action.yml +++ b/action.yml @@ -14,12 +14,21 @@ inputs: remote-path: description: 'REMOTE_NOTEBOOK_PATH' required: true + clean-workspace-remote-directory: + description: 'Removes objects recursive from the Databricks workspace specified REMOTE_NOTEBOOK_PATH' + required: false + default: false runs: using: "composite" steps: - id: import-notebooks - run: | + run: | + if [ $CLEAN_WORKSPACE_REMOTE_DIRECTORY = true ] + then + echo "Removes objects recursive from $REMOTE_NOTEBOOK_PATH in the workspace $DATABRICKS_HOST" + databricks workspace rm -r "${REMOTE_NOTEBOOK_PATH}" + fi echo "Uploading notebooks from $LOCAL_NOTEBOOKS_PATH to $REMOTE_NOTEBOOK_PATH in the workspace $DATABRICKS_HOST" databricks workspace import_dir --overwrite "${LOCAL_NOTEBOOKS_PATH}" "${REMOTE_NOTEBOOK_PATH}" --debug shell: bash @@ -28,3 +37,4 @@ runs: DATABRICKS_TOKEN: ${{ inputs.databricks-token}} LOCAL_NOTEBOOKS_PATH: ${{ inputs.local-path }} REMOTE_NOTEBOOK_PATH: ${{ inputs.remote-path }} + CLEAN_WORKSPACE_REMOTE_DIRECTORY: ${{ inputs.clean-workspace-remote-directory }}