The contents of this repository are pulled by Laravel Forge every time a site deployment is performed. The deploy script is then run to carry out the zero downtime deployment strategy. As such, it's essential that any changes to this script are tested thoroughly, and a new release is created when it is ready for use.
This script should be added to a Laravel Forge site's Deploy Script field to enable this functionality.
FORGE_PATH="/home/forge"
DEPLOY_SCRIPT_VERSION="v1.0.0"
DEPLOY_SCRIPT_URL="https://raw.githubusercontent.com/Bluegg/zero-downtime-deployment/$DEPLOY_SCRIPT_VERSION/deploy.sh"
DEPLOY_DIRECTORY="$FORGE_PATH/.deploy/$DEPLOY_SCRIPT_VERSION"
DEPLOY_SCRIPT="$DEPLOY_DIRECTORY/deploy.sh"
# Check if the deploy script exists, and if not, download it from GitHub
[ -f "$DEPLOY_SCRIPT" ] || { echo -e "\nDownloading Zero Downtime Deployment $DEPLOY_SCRIPT_VERSION..." && mkdir -p "$DEPLOY_DIRECTORY" && curl -o "$DEPLOY_SCRIPT" -sL "$DEPLOY_SCRIPT_URL"; }
# Check if the deploy script exists and run it, otherwise exit
[ -f "$DEPLOY_SCRIPT" ] && { source "$DEPLOY_SCRIPT"; } || { echo -e "\n$DEPLOY_SCRIPT does not exist." && exit 1; }