Databricks 자산 번들 및 GitHub Actions를 사용하여 CI/CD 워크플로 실행
이 문서에서는 GitHub Actions 및 Databricks 자산 번들을 사용하여 GitHub에서 CI/CD(지속적인 통합/지속적인 배포) 워크플로를 실행하는 방법을 설명합니다. Databricks 자산 번들이란?
Databricks CLI bundle
명령과 함께 GitHub Actions를 사용하여 GitHub 리포지토리 내에서 CI/CD 워크플로를 자동화, 사용자 지정 및 실행할 수 있습니다.
리포지토리의 .github/workflows
디렉터리에 다음과 같은 GitHub Actions YAML 파일을 추가할 수 있습니다. 다음 예제 GitHub Actions YAML 파일은 번들 구성 파일 내에 정의된 대로 "qa"라는 사전 프로덕션 대상 내에서 번들에서 지정된 작업의 유효성을 검사, 배포 및 실행합니다. 이 예제 GitHub Actions YAML 파일은 다음을 사용합니다.
- GitHub Actions YAML 파일의 설정을
working-directory: .
통해 명시적으로 선언되는 리포지토리의 루트에 있는 번들 구성 파일입니다(번들 구성 파일이 리포지토리의 루트에 이미 있는 경우 이 설정을 생략할 수 있습니다.) 이 번들 구성 파일은 명명된 Azure Databricks 워크플로와 명명my-job
qa
된 대상을 정의합니다. Databricks 자산 번들 구성을 참조 하세요. - 이 번들이 배포되고 실행되는 Azure Databricks 작업 영역과 연결된 Azure Databricks 서비스 주체에 대한 Azure Databricks 액세스 토큰을 나타내는 GitHub
SP_TOKEN
비밀입니다. 암호화된 비밀을 참조하세요.
# This workflow validates, deploys, and runs the specified bundle
# within a pre-production target named "qa".
name: "QA deployment"
# 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:
pull_request:
types:
- opened
- synchronize
branches:
- main
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
# 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.SP_TOKEN }}
DATABRICKS_BUNDLE_ENV: qa
# Validate, deploy, and then run the bundle.
pipeline_update:
name: "Run pipeline update"
runs-on: ubuntu-latest
# Run the "deploy" job first.
needs:
- deploy
steps:
# Check out this repo, so that this workflow can access it.
- uses: actions/checkout@v3
# Use the downloaded Databricks CLI.
- uses: databricks/setup-cli@main
# Run the Databricks workflow named "my-job" as defined in the
# bundle that was just deployed.
- run: databricks bundle run my-job --refresh-all
working-directory: .
env:
DATABRICKS_TOKEN: ${{ secrets.SP_TOKEN }}
DATABRICKS_BUNDLE_ENV: qa
다음 GitHub Actions YAML 파일은 이전 파일과 동일한 리포지토리에 있을 수 있습니다. 이 파일은 번들 구성 파일 내에 정의된 대로 "prod"라는 프로덕션 대상 내에서 지정된 번들의 유효성을 검사, 배포 및 실행합니다. 이 예제 GitHub Actions YAML 파일은 다음을 사용합니다.
- GitHub Actions YAML 파일의 설정을
working-directory: .
통해 명시적으로 선언되는 리포지토리의 루트에 있는 번들 구성 파일입니다(번들 구성 파일이 리포지토리의 루트에 이미 있는 경우 이 설정을 생략할 수 있음). 이 번들 구성 파일은 명명된 Azure Databricks 워크플로와 명명my-job
prod
된 대상을 정의합니다. Databricks 자산 번들 구성을 참조 하세요. - 이 번들이 배포되고 실행되는 Azure Databricks 작업 영역과 연결된 Azure Databricks 서비스 주체에 대한 Azure Databricks 액세스 토큰을 나타내는 GitHub
SP_TOKEN
비밀입니다. 암호화된 비밀을 참조하세요.
# This workflow validates, deploys, and runs the specified bundle
# within a production target named "prod".
name: "Production deployment"
# 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 pushed to the repo's
# main branch.
on:
push:
branches:
- main
jobs:
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
# Deploy the bundle to the "prod" target as defined
# in the bundle's settings file.
- run: databricks bundle deploy
working-directory: .
env:
DATABRICKS_TOKEN: ${{ secrets.SP_TOKEN }}
DATABRICKS_BUNDLE_ENV: prod
# Validate, deploy, and then run the bundle.
pipeline_update:
name: "Run pipeline update"
runs-on: ubuntu-latest
# Run the "deploy" job first.
needs:
- deploy
steps:
# Check out this repo, so that this workflow can access it.
- uses: actions/checkout@v3
# Use the downloaded Databricks CLI.
- uses: databricks/setup-cli@main
# Run the Databricks workflow named "my-job" as defined in the
# bundle that was just deployed.
- run: databricks bundle run my-job --refresh-all
working-directory: .
env:
DATABRICKS_TOKEN: ${{ secrets.SP_TOKEN }}
DATABRICKS_BUNDLE_ENV: prod
참고 항목
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기