echo"Error: $webhooks_file file not found in the script directory."
exit1
fi
# Messages to be sent to Slack
slack_failure_message=":rotating_light::rotating_light::rotating_light: One or more failures in dbt tests in production. :rotating_light::rotating_light::rotating_light:"
slack_success_message=":white_check_mark::white_check_mark::white_check_mark: dbt tests executed successfully in production. :white_check_mark::white_check_mark::white_check_mark:"
# Initialize the failure flag
has_any_step_failed=0
cd /home/azureuser/data-dwh-dbt-project
# Update from git
echo"Updating dbt project from git."
git checkout master
git pull
# Activate venv
source venv/bin/activate
# Run tests
echo"Triggering dbt test"
dbt test
if[$? -ne 0];then
has_any_step_failed=1
fi
# Check if any step failed and send a Slack message
if[$has_any_step_failed -eq 1];then
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$slack_failure_message\"}"$SLACK_ALERT_WEBHOOK_URL
fi
if[$has_any_step_failed -eq 0];then
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$slack_success_message\"}"$SLACK_RECEIPT_WEBHOOK_URL