After you stage your production websites to a non-production environment, you must run commands on your newly staged websites to synchronize them with your source environment’s data structure.
You can synchronize data with the post-staging-update hook for your environment. If you don’t create a post-staging-update hook script, Site Factory will instead execute the default drush updatedb command.
The post-staging-update hook executes only if the non-production and production environments aren’t running the same code.
For information on hook arguments, see Hook arguments.
Like several of the other hooks in use by Site Factory, you will create a script file following best practices for hook scripts. Place the script in a particular directory. Scripts in that directory are run in alphabetical order after the data copying process for each website being staged.
To use the post-staging-update hook:
Create a directory called factory-hooks in the root of your code repository, if it doesn’t already exist.
The factory-hooks and docroot directories are separate directories at the same level in your code repository.
post-staging-update directory in the factory-hooks directory, if it doesn’t already exist./factory-hooks/post-staging-update directory, add the script file or files you created for this procedure.After executing a staging deployment, review the newly staged website, as well as any logging output created by your hook script, to check if your hook script executed successfully.
If a script in the post-staging-update directory ends with an error (a non-zero exit code), no additional scripts will run in the directory, and the task logs will display error messages in SynchronizeSingleSite tasks.
Change the following script to meet your needs:
#!/usr/bin/env bash
SITEGROUP="$1"
ENVIRONMENT="$2"
DB_ROLE="$3"
DOMAIN="$4"
echo "sitegroup: $SITEGROUP"
echo "env: $ENVIRONMENT"
echo "db role: $DB_ROLE"
echo "domain: $DOMAIN"
\drush8 -r /var/www/html/$SITEGROUP.$ENVIRONMENT/docroot -l $DOMAIN ev 'echo "Hello world";'If this content did not answer your questions, try searching or contacting our support team for further assistance.
If this content did not answer your questions, try searching or contacting our support team for further assistance.