From 0361d87fb0631f1e22a0b2bee37f4cfb20ea364b Mon Sep 17 00:00:00 2001 From: Michael Cheung Date: Tue, 22 Jul 2025 01:34:17 +0800 Subject: [PATCH 1/2] fix: update cicd workflow to follow best practices --- .github/workflows/dev.yml | 58 +++++++++++++++++++++++++++++++++++ .github/workflows/staging.yml | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 .github/workflows/dev.yml create mode 100644 .github/workflows/staging.yml diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..55984ad --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,58 @@ +name: Deploy to Dev Environment + +concurrency: 1 + +on: + workflow_dispatch: + pull_request: + types: [opened, synchronize] + branches: [main] + paths: + - "**/*.yml" + - "**/*.py" + - "src/**" + - "resources/**" + +env: + DATABRICKS_BUNDLE_ENV: dev + DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }} + BUNDLE_VAR_databricks_user_email: ${{ secrets.DATABRICKS_USER_EMAIL }} + +jobs: + deploy: + name: Deploy bundle to dev environment + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Databricks CLI + uses: databricks/setup-cli@main + + - name: Install dependencies + run: pip install uv + + - name: Deploy Databricks bundle + run: databricks bundle deploy + + pipeline-update: + name: Run pipeline update + runs-on: ubuntu-latest + needs: deploy + if: success() + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Databricks CLI + uses: databricks/setup-cli@main + + - name: Run pipeline update + shell: bash + run: | + set -euo pipefail + echo "Starting pipeline update..." + databricks bundle run flightradar_databricks_job --refresh-all 2>&1 | tee pipeline_update.log + echo "Pipeline update completed successfully" \ No newline at end of file diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml new file mode 100644 index 0000000..07f5dee --- /dev/null +++ b/.github/workflows/staging.yml @@ -0,0 +1,57 @@ +name: Deploy to Staging Environment + +concurrency: 1 + +on: + workflow_dispatch: + push: + branches: [main] + paths: + - "**/*.yml" + - "**/*.py" + - "src/**" + - "resources/**" + +env: + DATABRICKS_BUNDLE_ENV: staging + DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }} + BUNDLE_VAR_databricks_user_email: ${{ secrets.DATABRICKS_USER_EMAIL }} + +jobs: + deploy: + name: Deploy bundle to staging environment + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Databricks CLI + uses: databricks/setup-cli@main + + - name: Install dependencies + run: pip install uv + + - name: Deploy Databricks bundle + run: databricks bundle deploy -t staging + + pipeline-update: + name: Run pipeline update + runs-on: ubuntu-latest + needs: deploy + if: success() + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Databricks CLI + uses: databricks/setup-cli@main + + - name: Run pipeline update + shell: bash + run: | + set -euo pipefail + echo "Starting pipeline update..." + databricks bundle run flightradar_databricks_job --refresh-all 2>&1 | tee pipeline_update.log + echo "Pipeline update completed successfully" \ No newline at end of file From 480042fa67cf6aea73643b514a89a7da38266dab Mon Sep 17 00:00:00 2001 From: Michael Cheung Date: Tue, 22 Jul 2025 01:41:15 +0800 Subject: [PATCH 2/2] fix: update env var to BUNDLE_VAR_user_email in github workflows --- .github/workflows/dev.yml | 2 +- .github/workflows/staging.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 55984ad..357922c 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -16,7 +16,7 @@ on: env: DATABRICKS_BUNDLE_ENV: dev DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }} - BUNDLE_VAR_databricks_user_email: ${{ secrets.DATABRICKS_USER_EMAIL }} + BUNDLE_VAR_user_email: ${{ secrets.DATABRICKS_USER_EMAIL }} jobs: deploy: diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 07f5dee..eb246da 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -15,7 +15,7 @@ on: env: DATABRICKS_BUNDLE_ENV: staging DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }} - BUNDLE_VAR_databricks_user_email: ${{ secrets.DATABRICKS_USER_EMAIL }} + BUNDLE_VAR_user_email: ${{ secrets.DATABRICKS_USER_EMAIL }} jobs: deploy: