Skip to content

Instantly share code, notes, and snippets.

@jameswilson
Created February 2, 2024 16:49
Show Gist options
  • Select an option

  • Save jameswilson/a83eaa00cd745a046f5dbe4e8bb8a6d9 to your computer and use it in GitHub Desktop.

Select an option

Save jameswilson/a83eaa00cd745a046f5dbe4e8bb8a6d9 to your computer and use it in GitHub Desktop.

Revisions

  1. jameswilson created this gist Feb 2, 2024.
    36 changes: 36 additions & 0 deletions deploy.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #!/bin/bash
    # Deployment script for Acquia Cloud Next on a multisite (non-Site Factory) setup.
    # Place this file in your repository at hooks/common/post-code-deploy/deploy.sh
    # See https://github.com/acquia/cloud-hooks/blob/master/samples/post-code-deploy.tmpl

    site="$1"
    target_env="$2"

    cd "/var/www/html/$site.$target_env/docroot"

    # Take all sites offline.
    for dir in sites/*/; do
    multisite_name=$(basename "$dir")
    DRUSH="../vendor/bin/drush --uri=$multisite_name"
    set -x # Expose the following command output to Acquia Cloud's Task Log.
    $DRUSH state:set system.maintenance_mode 1 --input-format=integer
    { set +x; } 2>&- # Hide the rest of the script output.
    done

    # Update each site and bring it back online as early as possible.
    # @todo parallelize update tasks across multisites using `parallel` command.
    for dir in sites/*/; do
    multisite_name=$(basename "$dir")
    DRUSH="../vendor/bin/drush --uri=$multisite_name"
    set -x # Expose the following command output to Acquia Cloud's Task Log.
    $DRUSH cache:rebuild
    $DRUSH updatedb
    $DRUSH config:import --yes
    $DRUSH config:import --yes
    $DRUSH cohesion:import
    $DRUSH sitestudio:package:import --yes
    $DRUSH state:set system.maintenance_mode 0 --input-format=integer
    $DRUSH cache:rebuild

    { set +x; } 2>&- # Hide the rest of the script output.
    done