From 5fa1dada0e2aed5e043e8032452434383c5328ed Mon Sep 17 00:00:00 2001 From: Suresh-Tamang Date: Sat, 16 May 2026 00:22:00 +0545 Subject: [PATCH 01/10] managed --- .../pipeline/data/load_tasty_bytes.sql | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/module-1/hamburg_weather/pipeline/data/load_tasty_bytes.sql b/module-1/hamburg_weather/pipeline/data/load_tasty_bytes.sql index 4565f538..11da4457 100644 --- a/module-1/hamburg_weather/pipeline/data/load_tasty_bytes.sql +++ b/module-1/hamburg_weather/pipeline/data/load_tasty_bytes.sql @@ -57,14 +57,15 @@ raw zone table build -- country table build -- todo: complete table build -CREATE TABLE {{env}}_tasty_bytes.raw_pos.country +CREATE OR ALTER TABLE {{env}}_tasty_bytes.raw_pos.country ( country_id NUMBER(18,0), country VARCHAR(16777216), iso_currency VARCHAR(3), iso_country VARCHAR(2), city VARCHAR(16777216), - city_population VARCHAR(16777216) + city_population VARCHAR(16777216), + city_id NUMBER(38,0) ); @@ -293,17 +294,17 @@ USE WAREHOUSE demo_build_wh; -- country table load --- COPY INTO {{env}}_tasty_bytes.raw_pos.country --- ( --- country_id, --- country, --- iso_currency, --- iso_country, --- city_id, --- city, --- city_population --- ) --- FROM @{{env}}_tasty_bytes.public.s3load/raw_pos/country/; +COPY INTO {{env}}_tasty_bytes.raw_pos.country +( + country_id, + country, + iso_currency, + iso_country, + city_id, + city, + city_population +) +FROM @{{env}}_tasty_bytes.public.s3load/raw_pos/country/; -- franchise table load From 66af34efa202af756d11367287588289644a65e0 Mon Sep 17 00:00:00 2001 From: Suresh Tamang <135485829+Suresh-Tamang@users.noreply.github.com> Date: Sun, 24 May 2026 09:28:28 +0545 Subject: [PATCH 02/10] create main.yml --- .github/workflows/main.yml | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..cf4845a7 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,67 @@ +name: Deploy Templatized Data Environment + +on: + pull_request: + types: [closed] + branches: + - staging + - main + push: + branches: + - staging + - main + +jobs: + deploy_data_environment: + # Only run when PR is merged or on direct push to environment branches + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) + runs-on: ubuntu-latest + + env: + # Read connection secret + SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} + SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} + SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} + + steps: + # Checkout step is necessary to access repository files + - name: Checkout repository + uses: actions/checkout@v4 + + # Determine environment based on target branch + - name: Set environment + id: set_env + run: | + TARGET_BRANCH="${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" + + if [[ $TARGET_BRANCH == "staging" ]]; then + echo "DEPLOY_ENV=staging" >> $GITHUB_ENV + echo "Environment set to staging" + elif [[ $TARGET_BRANCH == "main" ]]; then + echo "DEPLOY_ENV=prod" >> $GITHUB_ENV + echo "Environment set to production" + else + echo "Unexpected branch: $TARGET_BRANCH" + exit 1 + fi + + # Install Snowflake CLI GitHub Action and point to config file + - name: Install SnowflakeCLI + uses: snowflakedb/snowflake-cli-action@v1.5 + with: + cli-version: "latest" + default-config-file-path: "config.toml" + + # Fetch latest changes from the repository to Snowflake + - name: Fetch latest changes to Snowflake + run: snow git fetch course_repo.public.advanced_data_engineering_snowflake + + # Deploy templates to the data environment - + - name: Deploy templates to data environment + run: | + # Export TARGET_BRANCH for use in this step + echo "Using branch: ${GITHUB_REF_NAME}" + snow git execute @advanced_data_engineering_snowflake/branches/${ GITHU_REF_NAME}/module-1/hamburg_weather/pipeline/data/ \ + -D "env='${{ env.DEPLOY_ENV }}'" \ + --database=COURSE_REPO \ + --schema=PUBLIC From 7d8234810ebb04422652cb2fd84e619eeea09655 Mon Sep 17 00:00:00 2001 From: Suresh Tamang <135485829+Suresh-Tamang@users.noreply.github.com> Date: Sun, 24 May 2026 18:12:33 +0545 Subject: [PATCH 03/10] Update deployment command to use dynamic branch name --- module-1/hamburg_weather/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module-1/hamburg_weather/main.yml b/module-1/hamburg_weather/main.yml index bc93eac2..7e499155 100644 --- a/module-1/hamburg_weather/main.yml +++ b/module-1/hamburg_weather/main.yml @@ -61,7 +61,7 @@ jobs: run: | # Export TARGET_BRANCH for use in this step echo "Using branch: ${GITHUB_REF_NAME}" - snow git execute @advanced_data_engineering_snowflake/branches/FIX-ME/module-1/hamburg_weather/pipeline/data/ \ - -D "env='${{ }}'" \ + snow git execute @advanced_data_engineering_snowflake/branches/${GITHUB_REF_NAME}/module-1/hamburg_weather/pipeline/data/ \ + -D "env='${{env.DEPLOY_ENV}}'" \ --database=COURSE_REPO \ - --schema=PUBLIC \ No newline at end of file + --schema=PUBLIC From 32f064fb44f54153d4a6bbe0a15ed8c4c2e2a446 Mon Sep 17 00:00:00 2001 From: Suresh Tamang <135485829+Suresh-Tamang@users.noreply.github.com> Date: Sun, 24 May 2026 18:34:50 +0545 Subject: [PATCH 04/10] Refactor deployment workflow for Hamburg weather --- module-1/hamburg_weather/main.yml | 41 ++++++------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/module-1/hamburg_weather/main.yml b/module-1/hamburg_weather/main.yml index 7e499155..d14dacfb 100644 --- a/module-1/hamburg_weather/main.yml +++ b/module-1/hamburg_weather/main.yml @@ -1,39 +1,12 @@ -name: Deploy Templatized Data Environment - -on: - pull_request: - types: [closed] - branches: - - staging - - main - push: - branches: - - staging - - main - -jobs: - deploy_data_environment: - # Only run when PR is merged or on direct push to environment branches - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) - runs-on: ubuntu-latest - - env: - # Read connection secret - SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} - SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} - SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} - - steps: - # Checkout step is necessary to access repository files - - name: Checkout repository - uses: actions/checkout@v4 - - # Determine environment based on target branch +# Determine environment based on target branch - name: Set environment id: set_env run: | TARGET_BRANCH="${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" + # Save the clean target branch name for Git steps + echo "DEPLOY_BRANCH=$TARGET_BRANCH" >> $GITHUB_ENV + if [[ $TARGET_BRANCH == "staging" ]]; then echo "DEPLOY_ENV=staging" >> $GITHUB_ENV echo "Environment set to staging" @@ -59,9 +32,9 @@ jobs: # Deploy templates to the data environment - - name: Deploy templates to data environment run: | - # Export TARGET_BRANCH for use in this step - echo "Using branch: ${GITHUB_REF_NAME}" - snow git execute @advanced_data_engineering_snowflake/branches/${GITHUB_REF_NAME}/module-1/hamburg_weather/pipeline/data/ \ + # Use the new DEPLOY_BRANCH variable we safely calculated above + echo "Using branch: ${DEPLOY_BRANCH}" + snow git execute @advanced_data_engineering_snowflake/branches/${DEPLOY_BRANCH}/module-1/hamburg_weather/pipeline/data/ \ -D "env='${{env.DEPLOY_ENV}}'" \ --database=COURSE_REPO \ --schema=PUBLIC From 835471673114b07158b9bc74915481978121f342 Mon Sep 17 00:00:00 2001 From: Suresh Tamang <135485829+Suresh-Tamang@users.noreply.github.com> Date: Sun, 24 May 2026 18:40:41 +0545 Subject: [PATCH 05/10] Update main.yml --- module-1/hamburg_weather/main.yml | 41 +++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/module-1/hamburg_weather/main.yml b/module-1/hamburg_weather/main.yml index d14dacfb..7e499155 100644 --- a/module-1/hamburg_weather/main.yml +++ b/module-1/hamburg_weather/main.yml @@ -1,12 +1,39 @@ -# Determine environment based on target branch +name: Deploy Templatized Data Environment + +on: + pull_request: + types: [closed] + branches: + - staging + - main + push: + branches: + - staging + - main + +jobs: + deploy_data_environment: + # Only run when PR is merged or on direct push to environment branches + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) + runs-on: ubuntu-latest + + env: + # Read connection secret + SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} + SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} + SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} + + steps: + # Checkout step is necessary to access repository files + - name: Checkout repository + uses: actions/checkout@v4 + + # Determine environment based on target branch - name: Set environment id: set_env run: | TARGET_BRANCH="${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" - # Save the clean target branch name for Git steps - echo "DEPLOY_BRANCH=$TARGET_BRANCH" >> $GITHUB_ENV - if [[ $TARGET_BRANCH == "staging" ]]; then echo "DEPLOY_ENV=staging" >> $GITHUB_ENV echo "Environment set to staging" @@ -32,9 +59,9 @@ # Deploy templates to the data environment - - name: Deploy templates to data environment run: | - # Use the new DEPLOY_BRANCH variable we safely calculated above - echo "Using branch: ${DEPLOY_BRANCH}" - snow git execute @advanced_data_engineering_snowflake/branches/${DEPLOY_BRANCH}/module-1/hamburg_weather/pipeline/data/ \ + # Export TARGET_BRANCH for use in this step + echo "Using branch: ${GITHUB_REF_NAME}" + snow git execute @advanced_data_engineering_snowflake/branches/${GITHUB_REF_NAME}/module-1/hamburg_weather/pipeline/data/ \ -D "env='${{env.DEPLOY_ENV}}'" \ --database=COURSE_REPO \ --schema=PUBLIC From af13ba243163a72bbd901f60ec3aefe8834e8242 Mon Sep 17 00:00:00 2001 From: Suresh Tamang <135485829+Suresh-Tamang@users.noreply.github.com> Date: Sun, 24 May 2026 18:44:59 +0545 Subject: [PATCH 06/10] Update main.yml From ab360243a139e07a4586cc5a06fe8d1cb1619bc9 Mon Sep 17 00:00:00 2001 From: Suresh Tamang <135485829+Suresh-Tamang@users.noreply.github.com> Date: Sun, 24 May 2026 18:47:52 +0545 Subject: [PATCH 07/10] Update GitHub Actions workflow for deployment logic --- module-1/hamburg_weather/main.yml | 40 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/module-1/hamburg_weather/main.yml b/module-1/hamburg_weather/main.yml index 7e499155..e1c6fa34 100644 --- a/module-1/hamburg_weather/main.yml +++ b/module-1/hamburg_weather/main.yml @@ -6,6 +6,7 @@ on: branches: - staging - main + push: branches: - staging @@ -13,55 +14,58 @@ on: jobs: deploy_data_environment: - # Only run when PR is merged or on direct push to environment branches + # Run on push OR merged PR if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) + runs-on: ubuntu-latest env: - # Read connection secret SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} steps: - # Checkout step is necessary to access repository files - name: Checkout repository uses: actions/checkout@v4 - # Determine environment based on target branch + # Determine deployment environment + branch - name: Set environment id: set_env run: | TARGET_BRANCH="${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" - - if [[ $TARGET_BRANCH == "staging" ]]; then + + echo "TARGET_BRANCH=$TARGET_BRANCH" >> $GITHUB_ENV + + if [[ "$TARGET_BRANCH" == "staging" ]]; then echo "DEPLOY_ENV=staging" >> $GITHUB_ENV echo "Environment set to staging" - elif [[ $TARGET_BRANCH == "main" ]]; then + + elif [[ "$TARGET_BRANCH" == "main" ]]; then echo "DEPLOY_ENV=prod" >> $GITHUB_ENV echo "Environment set to production" + else echo "Unexpected branch: $TARGET_BRANCH" exit 1 fi - # Install Snowflake CLI GitHub Action and point to config file - - name: Install SnowflakeCLI + - name: Install Snowflake CLI uses: snowflakedb/snowflake-cli-action@v1.5 with: cli-version: "latest" default-config-file-path: "config.toml" - # Fetch latest changes from the repository to Snowflake - name: Fetch latest changes to Snowflake - run: snow git fetch course_repo.public.advanced_data_engineering_snowflake + run: | + snow git fetch course_repo.public.advanced_data_engineering_snowflake - # Deploy templates to the data environment - - name: Deploy templates to data environment run: | - # Export TARGET_BRANCH for use in this step - echo "Using branch: ${GITHUB_REF_NAME}" - snow git execute @advanced_data_engineering_snowflake/branches/${GITHUB_REF_NAME}/module-1/hamburg_weather/pipeline/data/ \ - -D "env='${{env.DEPLOY_ENV}}'" \ - --database=COURSE_REPO \ - --schema=PUBLIC + echo "Deploying branch: ${TARGET_BRANCH}" + echo "Deploy environment: ${DEPLOY_ENV}" + + snow git execute \ + @advanced_data_engineering_snowflake/branches/${TARGET_BRANCH}/module-1/hamburg_weather/pipeline/data/ \ + -D "env='${DEPLOY_ENV}'" \ + --database=COURSE_REPO \ + --schema=PUBLIC From 0b6ecbac8af81657db51f33f7e40036caa623456 Mon Sep 17 00:00:00 2001 From: Suresh Tamang <135485829+Suresh-Tamang@users.noreply.github.com> Date: Sun, 24 May 2026 19:30:16 +0545 Subject: [PATCH 08/10] Delete module-1/hamburg_weather/main.yml --- module-1/hamburg_weather/main.yml | 71 ------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 module-1/hamburg_weather/main.yml diff --git a/module-1/hamburg_weather/main.yml b/module-1/hamburg_weather/main.yml deleted file mode 100644 index e1c6fa34..00000000 --- a/module-1/hamburg_weather/main.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Deploy Templatized Data Environment - -on: - pull_request: - types: [closed] - branches: - - staging - - main - - push: - branches: - - staging - - main - -jobs: - deploy_data_environment: - # Run on push OR merged PR - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) - - runs-on: ubuntu-latest - - env: - SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} - SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} - SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Determine deployment environment + branch - - name: Set environment - id: set_env - run: | - TARGET_BRANCH="${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" - - echo "TARGET_BRANCH=$TARGET_BRANCH" >> $GITHUB_ENV - - if [[ "$TARGET_BRANCH" == "staging" ]]; then - echo "DEPLOY_ENV=staging" >> $GITHUB_ENV - echo "Environment set to staging" - - elif [[ "$TARGET_BRANCH" == "main" ]]; then - echo "DEPLOY_ENV=prod" >> $GITHUB_ENV - echo "Environment set to production" - - else - echo "Unexpected branch: $TARGET_BRANCH" - exit 1 - fi - - - name: Install Snowflake CLI - uses: snowflakedb/snowflake-cli-action@v1.5 - with: - cli-version: "latest" - default-config-file-path: "config.toml" - - - name: Fetch latest changes to Snowflake - run: | - snow git fetch course_repo.public.advanced_data_engineering_snowflake - - - name: Deploy templates to data environment - run: | - echo "Deploying branch: ${TARGET_BRANCH}" - echo "Deploy environment: ${DEPLOY_ENV}" - - snow git execute \ - @advanced_data_engineering_snowflake/branches/${TARGET_BRANCH}/module-1/hamburg_weather/pipeline/data/ \ - -D "env='${DEPLOY_ENV}'" \ - --database=COURSE_REPO \ - --schema=PUBLIC From b0411237eb1a8adf0e5fb3eeaa9a78b6e95dd4eb Mon Sep 17 00:00:00 2001 From: Suresh Tamang <135485829+Suresh-Tamang@users.noreply.github.com> Date: Sun, 24 May 2026 19:31:33 +0545 Subject: [PATCH 09/10] Delete .github/workflows/main.yml --- .github/workflows/main.yml | 67 -------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index cf4845a7..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Deploy Templatized Data Environment - -on: - pull_request: - types: [closed] - branches: - - staging - - main - push: - branches: - - staging - - main - -jobs: - deploy_data_environment: - # Only run when PR is merged or on direct push to environment branches - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) - runs-on: ubuntu-latest - - env: - # Read connection secret - SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} - SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} - SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} - - steps: - # Checkout step is necessary to access repository files - - name: Checkout repository - uses: actions/checkout@v4 - - # Determine environment based on target branch - - name: Set environment - id: set_env - run: | - TARGET_BRANCH="${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" - - if [[ $TARGET_BRANCH == "staging" ]]; then - echo "DEPLOY_ENV=staging" >> $GITHUB_ENV - echo "Environment set to staging" - elif [[ $TARGET_BRANCH == "main" ]]; then - echo "DEPLOY_ENV=prod" >> $GITHUB_ENV - echo "Environment set to production" - else - echo "Unexpected branch: $TARGET_BRANCH" - exit 1 - fi - - # Install Snowflake CLI GitHub Action and point to config file - - name: Install SnowflakeCLI - uses: snowflakedb/snowflake-cli-action@v1.5 - with: - cli-version: "latest" - default-config-file-path: "config.toml" - - # Fetch latest changes from the repository to Snowflake - - name: Fetch latest changes to Snowflake - run: snow git fetch course_repo.public.advanced_data_engineering_snowflake - - # Deploy templates to the data environment - - - name: Deploy templates to data environment - run: | - # Export TARGET_BRANCH for use in this step - echo "Using branch: ${GITHUB_REF_NAME}" - snow git execute @advanced_data_engineering_snowflake/branches/${ GITHU_REF_NAME}/module-1/hamburg_weather/pipeline/data/ \ - -D "env='${{ env.DEPLOY_ENV }}'" \ - --database=COURSE_REPO \ - --schema=PUBLIC From 297d25fe857eca08d974a36b554ed3a72338ce4d Mon Sep 17 00:00:00 2001 From: Suresh Tamang <135485829+Suresh-Tamang@users.noreply.github.com> Date: Sun, 24 May 2026 19:36:09 +0545 Subject: [PATCH 10/10] Add GitHub Actions workflow for data environment deployment --- .github/workflows/main.yml | 71 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..e1c6fa34 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,71 @@ +name: Deploy Templatized Data Environment + +on: + pull_request: + types: [closed] + branches: + - staging + - main + + push: + branches: + - staging + - main + +jobs: + deploy_data_environment: + # Run on push OR merged PR + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) + + runs-on: ubuntu-latest + + env: + SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }} + SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }} + SNOWFLAKE_CONNECTIONS_ADVANCED_DATA_ENGINEERING_SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Determine deployment environment + branch + - name: Set environment + id: set_env + run: | + TARGET_BRANCH="${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}" + + echo "TARGET_BRANCH=$TARGET_BRANCH" >> $GITHUB_ENV + + if [[ "$TARGET_BRANCH" == "staging" ]]; then + echo "DEPLOY_ENV=staging" >> $GITHUB_ENV + echo "Environment set to staging" + + elif [[ "$TARGET_BRANCH" == "main" ]]; then + echo "DEPLOY_ENV=prod" >> $GITHUB_ENV + echo "Environment set to production" + + else + echo "Unexpected branch: $TARGET_BRANCH" + exit 1 + fi + + - name: Install Snowflake CLI + uses: snowflakedb/snowflake-cli-action@v1.5 + with: + cli-version: "latest" + default-config-file-path: "config.toml" + + - name: Fetch latest changes to Snowflake + run: | + snow git fetch course_repo.public.advanced_data_engineering_snowflake + + - name: Deploy templates to data environment + run: | + echo "Deploying branch: ${TARGET_BRANCH}" + echo "Deploy environment: ${DEPLOY_ENV}" + + snow git execute \ + @advanced_data_engineering_snowflake/branches/${TARGET_BRANCH}/module-1/hamburg_weather/pipeline/data/ \ + -D "env='${DEPLOY_ENV}'" \ + --database=COURSE_REPO \ + --schema=PUBLIC