Created
August 3, 2018 10:11
-
-
Save willis7/08a162776f2131c1f998b61f30eaf968 to your computer and use it in GitHub Desktop.
Blue Green Deployment with Cloud Foundry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
cf login -a "$CF_API" -u "$CF_USER" -p "$CF_PASSWORD" -o "$CF_ORG" -s "$CF_SPACE" | |
APP_NAME_TMP="${APP_NAME}-venerable" | |
# Deploy a new application if doesn't exist and do blue-green otherwise | |
if [[ $(cf app "$APP_NAME" --guid 2>&1 1>/dev/null) == "App $APP_NAME not found" ]]; then | |
cf push | |
else | |
cf rename "$APP_NAME" "$APP_NAME_TMP" | |
if cf push; then | |
cf delete -f "$APP_NAME_TMP" | |
else | |
cf delete -f "$APP_NAME" | |
cf rename "$APP_NAME_TMP" "$APP_NAME" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment