Pre-deploy Steps
Overview
Pre-deploy steps are tasks that automatically run before every deployment. They are created from Commands and execute sequentially in the order you specify. If any pre-deploy step fails, the entire deployment is aborted.
Purpose and Benefits
- Database Migrations: Run schema changes before new code is deployed
- Smoke Tests: Validate application startup and critical functionality
- Data Preparation: Prepare data or caches before the new version goes live
- No Deployment Delays: Pre-deploy tasks run independently of ECS rollout timing, so they can take as long as needed without affecting deployment timeouts
- Ordered Execution: Control the sequence of operations with drag-and-drop reordering in the UI
- Fail-Safe: Deployments are blocked if any pre-deploy step fails, preventing broken releases
How Pre-deploy Steps Work
- Triggered Automatically: When a deployment starts, all pre-deploy steps run before any containers are updated
- Sequential Execution: Steps run in their configured order (by position)
- Blocking on Failure: If any step fails, the deployment is aborted immediately
- Independent Timing: Steps run as ECS tasks with no connection to deployment timeout limits
CLI Usage
Create Pre-deploy Step
tapit create predeploy_step name=command-nameCreates a pre-deploy step that will run the specified command before every deployment.
Required Parameters
name: The name of an existing Command to run as a pre-deploy step
Example
# First, create a command for database migrations
tapit create command name=db-migrate 'rails db:migrate' description='Run database migrations'
# Then add it as a pre-deploy step
tapit create predeploy_step name=db-migrateList Pre-deploy Steps
tapit list predeploy_stepsShows all configured pre-deploy steps with their position and associated command.
Example Output
Position Command Name Command
1 db-migrate rails db:migrate
2 smoke-test rails runner 'AppHealthCheck.verify!'Delete Pre-deploy Step
tapit delete predeploy_step name=command-nameRemoves a pre-deploy step. The underlying command is not deleted.
Required Parameters
name: The name of the command associated with the pre-deploy step to remove
Web Interface
Pre-deploy steps can be managed from the App Settings menu under Pre-deploy steps:
- Add Steps: Select from existing commands to add as pre-deploy steps
- Reorder Steps: Drag and drop to change the execution order
- Remove Steps: Delete steps that are no longer needed
Common Use Cases
Database Migrations
# Create migration command
tapit create command name=db-migrate 'rails db:migrate' description='Run database migrations'
# Add as pre-deploy step
tapit create predeploy_step name=db-migrateApplication Smoke Tests
# Create smoke test command
tapit create command name=smoke-test 'rails runner "AppHealthCheck.verify!"' description='Verify app starts correctly'
# Add as pre-deploy step
tapit create predeploy_step name=smoke-testAsset Compilation or Cache Warming
# Create cache warming command
tapit create command name=warm-cache 'rails runner "CacheWarmer.run"' description='Pre-warm application caches'
# Add as pre-deploy step
tapit create predeploy_step name=warm-cacheMultiple Pre-deploy Steps
# Create commands
tapit create command name=db-migrate 'rails db:migrate'
tapit create command name=db-seed-config 'rails runner "ConfigSeeder.run"'
tapit create command name=smoke-test 'rails runner "SmokeTest.run"'
# Add as pre-deploy steps (they run in the order added, reorder in UI if needed)
tapit create predeploy_step name=db-migrate
tapit create predeploy_step name=db-seed-config
tapit create predeploy_step name=smoke-testBest Practices
- Keep Steps Fast: While steps can take as long as needed, faster steps mean faster deployments
- Idempotent Operations: Design commands to be safely re-runnable in case of deployment retries
- Meaningful Names: Use descriptive command names that indicate what the step does
- Order Matters: Place critical operations (like migrations) before validation steps (like smoke tests)
- Test Commands First: Run commands manually with
tapit create task 'command'before adding them as pre-deploy steps
Troubleshooting
Pre-deploy Step Fails
If a pre-deploy step fails:
- The deployment is aborted and no containers are updated
- Check the task logs for the failed step to identify the issue
- Fix the underlying problem
- Retry the deployment
# Check recent task logs
tapit show logs
# List recent tasks to find the failed pre-deploy task
tapit list tasksStep Order Issues
If steps need to run in a different order:
- Use the web interface to drag and drop steps into the correct order
- Or delete and re-add steps in the desired order via CLI