Updated tinybird unsafe deploy script (#21135)

ref https://github.com/TryGhost/Ghost/pull/21092

- This updates the unsafe deploy script to be safer and more useful
This commit is contained in:
Hannah Wolfe 2024-09-26 15:54:08 +01:00 committed by GitHub
parent 21ecd9c2af
commit 908ff731d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

27
ghost/tinybird/scripts/unsafe_redeploy.sh Normal file → Executable file
View File

@ -1,3 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
# Check if --force flag is provided
force=false
if [[ "$@" == *"--force"* ]]; then
force=true
fi
# Get current branch info
branch_info=$(tb branch current)
# Check if 'main' and 'production_stats' are both present in the output
if echo "$branch_info" | grep -q "main" && echo "$branch_info" | grep -q "production_stats"; then
if [ "$force" = false ]; then
echo "🚨 ERROR: Attempting to run unsafe_redeploy on main branch in production_stats workspace."
echo "If you're sure you want to do this, run the script with the --force flag."
exit 1
else
echo "⚠️ WARNING: Running unsafe_redeploy on main branch in production_stats workspace with --force flag."
fi
fi
echo "Proceeding with unsafe redeploy..."
# Remove our materialized views and their pipes
tb datasource rm analytics_pages_mv --yes
tb datasource rm analytics_sessions_mv --yes
@ -17,4 +42,4 @@ tb pipe rm pipes/top_sources.pipe --yes
tb pipe rm pipes/trend.pipe --yes
# Push all the changes
tb push --only-changes --force --populate
tb push --force --populate