Files
doczyai-pipelines/bitbucket-pipelines.yml
T

66 lines
2.1 KiB
YAML
Raw Normal View History

2024-02-06 16:29:58 -06:00
definitions:
steps:
- step: &terraform_plan_apply
name: "Plan and Apply Terraform"
image: zenika/terraform-aws-cli:latest
script:
- terraform --version
# terraform steps here
2024-02-12 12:24:23 -06:00
trigger: automatic # uncomment after testing
# trigger: manual
2024-02-06 16:29:58 -06:00
- step: &snowflake_deploy
name: "Deploy Snowflake Changes"
image: python:3.7
size: 2x
script:
- python -m pip install --upgrade pip
- pip install snowflake-connector-python
- pip install schemachange --upgrade
# Setting the database name dynamically based on the branch name
- if [ "$BITBUCKET_BRANCH" == "DEV" ]; then export SNOWFLAKE_DATABASE=$DEV_SNOWFLAKE_DATABASE; fi
- if [ "$BITBUCKET_BRANCH" == "UAT" ]; then export SNOWFLAKE_DATABASE=$UAT_SNOWFLAKE_DATABASE; fi
- if [ "$BITBUCKET_BRANCH" == "PROD" ]; then export SNOWFLAKE_DATABASE=$PROD_SNOWFLAKE_DATABASE; fi
- schemachange -a $SNOWFLAKE_ACCOUNT -u $SNOWFLAKE_USER -r $SNOWFLAKE_ROLE -w $SNOWFLAKE_WAREHOUSE -d $SNOWFLAKE_DATABASE -c $SNOWFLAKE_DATABASE.SCHEMACHANGE.CHANGE_HISTORY --create-change-history-table -v
2024-02-12 12:24:23 -06:00
trigger: automatic # uncomment after testing
# trigger: manual
2024-02-06 16:29:58 -06:00
caches:
- pip
pipelines:
branches:
2024-02-12 12:11:27 -06:00
DEV:
2024-02-06 16:29:58 -06:00
- step:
<<: *terraform_plan_apply
condition:
changesets:
includePaths:
2024-02-12 12:15:01 -06:00
- terraform/environments/dev/**/*
2024-02-06 16:29:58 -06:00
- step:
<<: *snowflake_deploy
condition:
2024-02-12 12:18:38 -06:00
changesets:
includePaths:
2024-02-06 16:29:58 -06:00
- snowflake/**/*.sql
uat:
- step:
<<: *terraform_plan_apply
condition:
paths:
- terraform/uat/**/*
- step:
<<: *snowflake_deploy
condition:
paths:
- snowflake/**/*.sql
prod:
- step:
<<: *terraform_plan_apply
condition:
paths:
- terraform/prod//**/*
- step:
<<: *snowflake_deploy
condition:
paths:
- snowflake/**/*.sql