DLT Deploy on PR #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow validates, deploys, and runs the specified bundle | |
# within a pre-production target named "qa". | |
name: "DLT Deploy on PR" | |
# Ensure that only a single job or workflow using the same concurrency group | |
# runs at a time. | |
concurrency: 1 | |
# Trigger this workflow whenever a pull request is opened against the repo's | |
# main branch or an existing pull request's head branch is updated. | |
on: | |
workflow_dispatch: | |
inputs: | |
target: | |
description: 'Target deployment environment' | |
type: choice | |
required: true | |
options: | |
- dev | |
- sandbox | |
jobs: | |
# Used by the "pipeline_update" job to deploy the bundle. | |
# Bundle validation is automatically performed as part of this deployment. | |
# If validation fails, this workflow fails. | |
deploy: | |
name: "Deploy bundle" | |
runs-on: ubuntu-latest | |
steps: | |
# Check out this repo, so that this workflow can access it. | |
- uses: actions/checkout@v3 | |
# Download the Databricks CLI. | |
# See https://github.com/databricks/setup-cli | |
- uses: databricks/setup-cli@main | |
- name: Replace pipeline name and schema | |
working-directory: . | |
env: | |
PIPELINE_ORIGIN_NAME: dlt_sample_pipeline | |
PIPELINE_ORIGIN_SCHEMA: base_schema_name | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
BANDLE_NAME: dlt_sample | |
run: | | |
BRANCH_NAME=`echo "$BRANCH_NAME" | sed -r 's/[/]+/_/g'` | |
sed -i -e s/${PIPELINE_ORIGIN_NAME}/${PIPELINE_ORIGIN_NAME}_${BRANCH_NAME}/g resources/dlt_sample_pipeline.yml | |
sed -i -e s/${PIPELINE_ORIGIN_SCHEMA}/${PIPELINE_ORIGIN_SCHEMA}_${BRANCH_NAME}/g resources/dlt_sample_pipeline.yml | |
sed -i -e s/${BANDLE_NAME}/${BANDLE_NAME}_${BRANCH_NAME}/g databricks.yml | |
# Deploy the bundle to the "qa" target as defined | |
# in the bundle's settings file. | |
- run: databricks bundle deploy | |
working-directory: . | |
env: | |
DATABRICKS_TOKEN: ${{ secrets.DB_TOKEN }} | |
DATABRICKS_BUNDLE_ENV: dev |