diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index f86d6f7..b495966 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -1,5 +1,22 @@ definitions: steps: + - 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; export SNOWFLAKE_ROLE=$DEV_SNOWFLAKE_ROLE; fi + - if [ "$BITBUCKET_BRANCH" == "UAT" ]; then export SNOWFLAKE_DATABASE=$UAT_SNOWFLAKE_DATABASE; export SNOWFLAKE_ROLE=$UAT_SNOWFLAKE_ROLE; fi + - if [ "$BITBUCKET_BRANCH" == "PROD" ]; then export SNOWFLAKE_DATABASE=$PROD_SNOWFLAKE_DATABASE; export SNOWFLAKE_ROLE=$PROD_SNOWFLAKE_ROLE; 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 + trigger: automatic + # trigger: manual + caches: + - pip - step: &terraform_plan_apply name: "Plan and Apply Terraform" image: python:3.8 @@ -22,23 +39,6 @@ definitions: - terraform apply -auto-approve -no-color -var 'access_key=$AWS_ACCESS_KEY_ID' -var 'secret_key=$AWS_SECRET_ACCESS_KEY' -var 'aws_region=us-east-2' -var 'environment=$BRANCH_NAME_LOWER' # trigger: automatic # uncomment after testing trigger: manual - - 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; export SNOWFLAKE_ROLE=$DEV_SNOWFLAKE_ROLE; fi - - if [ "$BITBUCKET_BRANCH" == "UAT" ]; then export SNOWFLAKE_DATABASE=$UAT_SNOWFLAKE_DATABASE; export SNOWFLAKE_ROLE=$UAT_SNOWFLAKE_ROLE; fi - - if [ "$BITBUCKET_BRANCH" == "PROD" ]; then export SNOWFLAKE_DATABASE=$PROD_SNOWFLAKE_DATABASE; export SNOWFLAKE_ROLE=$PROD_SNOWFLAKE_ROLE; 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 - trigger: automatic - # trigger: manual - caches: - - pip - step: &streamlit_deploy name: "Deploy streamlit to EC2" oidc: true