Deploy Hooks let you run custom commands at different stages of your deployment process. Configure them in your app’s Deploy Hooks settings.
Available Hooks
🔨 Post Build Hook
When: After buildpack/build, before final image Perfect for: Installing packages, setting up tools, custom build steps Failure impact: Stops build - image won’t be created
# Install packages
apt-get update && apt-get install -y curl jq postgresql-client
# Or use a build script
.blossom/post-build
🚀 Release Phase Hook
When: Before each deployment, after build Perfect for: Database migrations, cache warming, setup tasks Failure impact: Stops deployment
# Database migrations
bundle exec rails db:migrate
python manage.py migrate
npm run migrate
# Cache warming
bundle exec rails runner 'CacheWarmupJob.perform_later'
✅ Post Deploy Hook
When: After successful deployment Perfect for: Notifications, cleanup, monitoring setup Failure impact: Doesn’t affect deployment - app keeps running
# Send notifications
curl -X POST $WEBHOOK_URL/deployed
# Background tasks
bundle exec rails runner 'NotificationJob.perform_later'
Quick Setup
- Enable the hook in Deploy Hooks settings
- Enter your command (or reference a script file)
- Deploy - hooks run automatically
Build Scripts (Recommended)
For complex Post Build Hooks, create .blossom/post-build
:
#!/bin/bash
set -e
echo "===> Installing packages..."
apt-get update && apt-get install -y curl jq
echo "===> Setting up environment..."
echo "export CUSTOM_VAR=value" >> /etc/environment
echo "===> Post build completed"
Then use: .blossom/post-build
in your Post Build Hook setting.
What You Can Do
- Install packages:
apt-get install -y curl jq
- Run migrations:
bundle exec rails db:migrate
- Send notifications:
curl -X POST $WEBHOOK_URL/deployed
- Warm caches:
bundle exec rails runner 'CacheWarmupJob.perform_later'
- Setup monitoring: Install monitoring tools, configure alerts
- Custom setup: Any command your app needs