Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ Sample scripts currently include:
* post-code-update.tmpl: Template for post-code-update hook scripts.
* post-db-copy.tmpl: Template for post-db-copy hook scripts.
* post-files-copy.tmpl: Template for post-files-copy hook scripts.
* pre-site-code-deploy.tmpl: Template for pre-site-code-deploy hook scripts.
* post-site-code-deploy.tmpl: Template for post-site-code-deploy hook scripts.
* update-db.sh: Run drush updatedb to perform database updates.
* db-scrub.sh: Scrub important information from a Drupal database.
* maintenance-mode-enable.sh: Enable Drupal maintenance mode before site deployment.
* maintenance-mode-disable-and-update.sh: Disable maintenance mode and optionally run database updates after site deployment.
* drupal-tests.sh: Run Drupal simpletests.
* rollback.sh: Run designated simpletest testing against a branch/tag and rollback on failure.
* newrelic.sh: Example of Acquia Hosting Cloud Hook to notify New Relic API of code version deployments.
Expand Down Expand Up @@ -156,3 +160,43 @@ Usage: post-files-copy site target-env source-env
Example: When you use the Workflow page to drag files from Prod to Dev, the files-copy hook will be run like:

post-files-copy mysite prod dev

### pre-site-code-deploy

The pre-site-code-deploy hook is run before code is deployed to a specific site via the Acquia Cloud UI or API. This is a site-level deployment hook that allows you to prepare a site for deployment, such as enabling maintenance mode.

Usage: pre-site-code-deploy site target-env source-branch deployed-tag repo-url repo-type site-name extra-args

* site: The site name. This is the same as the Acquia Cloud username for the site.
* target-env: The environment to which code is being deployed.
* source-branch: The code branch or tag being deployed.
* deployed-tag: The code branch or tag being deployed.
* repo-url: The URL of your code repository.
* repo-type: The version control system your site is using; "git".
* site-name: The specific site name being deployed to.
* extra-args: Optional parameters passed from the Acquia Cloud UI or API. Empty string if none provided.

Example: When deploying code to a site via the Cloud UI or API, the pre-site-code-deploy hook will be run like:

pre-site-code-deploy mysite prod master tags/2026-06-29 mysite@svn-3.devcloud.hosting.acquia.com:mysite.git git siteName ""
Comment thread
blkperl marked this conversation as resolved.
Outdated

### post-site-code-deploy

The post-site-code-deploy hook is run after code has been deployed to a specific site via the Acquia Cloud UI or API. This is a site-level deployment hook that allows you to perform post-deployment tasks, such as disabling maintenance mode or running database updates.

Usage: post-site-code-deploy site target-env source-branch deployed-tag repo-url repo-type site-name extra-args

* site: The site name. This is the same as the Acquia Cloud username for the site.
* target-env: The environment to which code was deployed.
* source-branch: The code branch or tag that was deployed.
* deployed-tag: The code branch or tag that was deployed.
* repo-url: The URL of your code repository.
* repo-type: The version control system your site is using; "git".
* site-name: The specific site name that was deployed to.
* extra-args: Optional parameters passed from the Acquia Cloud UI or API. Empty string if none provided.

The extra-args parameter allows you to pass custom parameters from the Cloud UI or API to trigger specific behaviors in your hook scripts, such as running database updates.

Example: When deploying code to a site with extra arguments requesting database updates, the post-site-code-deploy hook will be run like:

post-site-code-deploy mysite prod master tags/2026-06-29 mysite@svn-3.devcloud.hosting.acquia.com:mysite.git git siteName "update-db"
Comment thread
blkperl marked this conversation as resolved.
Outdated
4 changes: 4 additions & 0 deletions common/post-site-code-deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
4 changes: 4 additions & 0 deletions common/pre-site-code-deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
4 changes: 4 additions & 0 deletions dev/post-site-code-deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
4 changes: 4 additions & 0 deletions dev/pre-site-code-deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
4 changes: 4 additions & 0 deletions prod/post-site-code-deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
4 changes: 4 additions & 0 deletions prod/pre-site-code-deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
40 changes: 40 additions & 0 deletions samples/maintenance-mode-disable-and-update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh
#
# Cloud Hook: maintenance-mode-disable-and-update
#
# Disable Drupal maintenance mode after a site-level code deployment and
# optionally run database updates if requested via extra-args. This script
# is intended to be used as a post-site-code-deploy hook.
#
# To trigger database updates, pass "update-db" or "updatedb" in the
# extra-args parameter when deploying via the Acquia Cloud UI or API.
#
# Usage: maintenance-mode-disable-and-update site target-env source-branch
# deployed-tag repo-url repo-type
# site-name extra-args

site="$1"
target_env="$2"
source_branch="$3"
deployed_tag="$4"
repo_url="$5"
repo_type="$6"
site_name="$7"
extra_args="$8"

echo "$site.$target_env: Disabling maintenance mode for site $site_name after deployment."

# Disable maintenance mode for Drupal 8/9/10/11
# For Drupal 7, use: drush @$site.$target_env vset maintenance_mode 0
drush @$site.$target_env state:set system.maintenance_mode 0 --input-format=integer

echo "$site.$target_env: Maintenance mode disabled for $site_name."

# Check if database updates were requested via extra-args
if echo "$extra_args" | grep -q "update-db\|updatedb"; then
echo "$site.$target_env: Running database updates for $site_name (requested via extra-args)."
drush @$site.$target_env updatedb --yes
echo "$site.$target_env: Database updates completed for $site_name."
else
echo "$site.$target_env: No database updates requested for $site_name."
fi
27 changes: 27 additions & 0 deletions samples/maintenance-mode-enable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
#
# Cloud Hook: maintenance-mode-enable
#
# Enable Drupal maintenance mode before a site-level code deployment.
# This script is intended to be used as a pre-site-code-deploy hook to
# ensure the site is in maintenance mode during deployment.
#
# Usage: maintenance-mode-enable site target-env source-branch deployed-tag
# repo-url repo-type site-name extra-args

site="$1"
target_env="$2"
source_branch="$3"
deployed_tag="$4"
repo_url="$5"
repo_type="$6"
site_name="$7"
extra_args="$8"

echo "$site.$target_env: Enabling maintenance mode for site $site_name before deployment."

# Enable maintenance mode for Drupal 8/9/10/11
# For Drupal 7, use: drush @$site.$target_env vset maintenance_mode 1
drush @$site.$target_env state:set system.maintenance_mode 1 --input-format=integer

echo "$site.$target_env: Maintenance mode enabled for $site_name."
22 changes: 22 additions & 0 deletions samples/post-site-code-deploy.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
#
# Cloud Hook: post-site-code-deploy
#
# The post-site-code-deploy hook is run after code has been deployed to a
# specific site via the Acquia Cloud UI or API. This is a site-level hook
# that allows you to perform post-deployment tasks, such as disabling
# maintenance mode or running database updates. See ../README.md for details.
#
# Usage: post-site-code-deploy site target-env source-branch deployed-tag repo-url
# repo-type site-name extra-args

site="$1"
target_env="$2"
source_branch="$3"
deployed_tag="$4"
repo_url="$5"
repo_type="$6"
site_name="$7"
extra_args="$8"

echo "$site.$target_env: Completed deployment of $deployed_tag to site $site_name."
22 changes: 22 additions & 0 deletions samples/pre-site-code-deploy.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
#
# Cloud Hook: pre-site-code-deploy
#
# The pre-site-code-deploy hook is run before code is deployed to a specific
# site via the Acquia Cloud UI or API. This is a site-level hook that allows
# you to prepare a site for deployment, such as enabling maintenance mode.
# See ../README.md for details.
#
# Usage: pre-site-code-deploy site target-env source-branch deployed-tag repo-url
# repo-type site-name extra-args

site="$1"
target_env="$2"
source_branch="$3"
deployed_tag="$4"
repo_url="$5"
repo_type="$6"
site_name="$7"
extra_args="$8"

echo "$site.$target_env: Preparing to deploy $deployed_tag to site $site_name."
4 changes: 4 additions & 0 deletions test/post-site-code-deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
4 changes: 4 additions & 0 deletions test/pre-site-code-deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore