script to build and place docs
This commit is contained in:
parent
c209e670ca
commit
898c482172
1 changed files with 63 additions and 0 deletions
63
run_docs.sh
Normal file
63
run_docs.sh
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
exec >> /home/azureuser/dbt_docs.log 2>&1
|
||||||
|
|
||||||
|
# Define the Slack webhook URL
|
||||||
|
script_dir=$(dirname "$0")
|
||||||
|
webhooks_file="slack_webhook_urls.txt"
|
||||||
|
env_file="$script_dir/$webhooks_file"
|
||||||
|
if [ -f "$env_file" ]; then
|
||||||
|
export $(grep -v '^#' "$env_file" | xargs)
|
||||||
|
else
|
||||||
|
echo "Error: $webhooks_file file not found in the script directory."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Messages to be sent to Slack
|
||||||
|
slack_failure_message=":rotating_light::rotating_light::rotating_light: One or more failures in dbt docs build in production. :rotating_light::rotating_light::rotating_light:"
|
||||||
|
slack_success_message=":white_check_mark::white_check_mark::white_check_mark: dbt docs built 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 docs generate"
|
||||||
|
dbt docs generate
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
has_any_step_failed=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Read the first argument as the target directory
|
||||||
|
docs_final_target_directory=$1
|
||||||
|
|
||||||
|
# Check if the target directory is provided
|
||||||
|
if [ -z "$docs_final_target_directory" ]; then
|
||||||
|
echo "Error: No target directory provided."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Copy the generated docs to the target directory
|
||||||
|
echo "Copying generated docs to $docs_final_target_directory."
|
||||||
|
cp -r target/* "$docs_final_target_directory"
|
||||||
|
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
|
||||||
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue