Skip to content

Instantly share code, notes, and snippets.

@hanoii
Created May 29, 2018 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanoii/d787053f5c7874226ecb6173d423000f to your computer and use it in GitHub Desktop.
Save hanoii/d787053f5c7874226ecb6173d423000f to your computer and use it in GitHub Desktop.
Platform app yaml for the wordpress example allowing to update database on sync/branch through wp-cli
# Only the necessary entries are on this file.
# IT IS NOT A COMPLETE .platform.app.yaml FILE.
# The mounts that will be performed when the package is deployed.
mounts:
"/deploy": "shared:files/deploy"
hooks:
deploy: |
DEPLOY_FILE=/app/deploy/deploy.url
CURRENT=`echo "import sys\nimport os\nimport json\nroutes=json.loads(os.environ['PLATFORM_ROUTES'].decode('base64'))\nfor i in routes:\n\tif routes[i]['type'] == 'upstream' and routes[i]['upstream'] == os.environ['PLATFORM_APPLICATION_NAME']: sys.stdout.write(i.strip('/'))" | python`
PREVIOUS=`[ -f $DEPLOY_FILE ] && cat $DEPLOY_FILE`
echo
if [ "$CURRENT" != "$PREVIOUS" ]; then
wp search-replace $PREVIOUS $CURRENT --skip-columns=guid
fi
echo $CURRENT > $DEPLOY_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment