Use a script for deploying or staging

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the workflows category.

Last Updated: 2024-03-28

I pushed Project X to Heroku with git push heroku. One time, there was a database migration I forgot to run. This caused logging in staging to fail for other developers during the time I was off work the next day.

The fix was a script to handle the deploy to staging, one that does migrations etc.: bin/stage

#!/usr/bin/env bash

echo
echo "Pushing development branch to Github"
git push

echo
echo "Deploying staging environment to Heroku"
# We assume that Heroku is set up to build on the master branch
git push staging development:master
echo
echo "Migrating database"
heroku run php artisan migrate --remote staging