• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
  • Created about 13 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Acquia Cloud hook scripts and documentation

What are Cloud Hooks?

Cloud Hooks is a feature of Acquia Cloud, the Drupal cloud hosting platform. For more information, see https://www.acquia.com/products-services/acquia-dev-cloud.

The Acquia Cloud Workflow page automates the most common tasks involved in developing a Drupal site: deploying code from a version control system, and migrating code, databases, and files across your Development, Staging, and Production environments. Cloud Hooks allow you to automate other tasks as part of these migrations.

A Cloud Hook is simply a script in your code repository that Acquia Cloud executes on your behalf when a triggering action occurs. Examples of tasks that you can automate with Cloud Hooks include:

  • Perform Drupal database updates each time new code is deployed.
  • "Scrub" your Production database when it is copied to Dev or Staging by removing customer emails or disabling production-only modules.
  • Run your test suite or a site performance test each time new code is deployed.

Installing Cloud Hooks

Cloud hook scripts live in your Acquia Cloud code repository. In each branch of your repo, there is a directory named docroot that contains your site's source code. Cloud hooks live in the directory hooks NEXT TO docroot (not inside of docroot).

To install the correct directory structure and sample hook scripts, simply copy this repo into your Acquia Cloud repo.

cd /my/repo
curl -L -o hooks.tar.gz https://github.com/acquia/cloud-hooks/tarball/master
tar xzf hooks.tar.gz
mv acquia-cloud-hooks-* hooks
git add hooks
git commit -m 'Import Cloud hooks directory and sample scripts.'
git push

Quick Start

To get an idea of the power of Cloud Hooks, let's run the "Hello, Cloud!" script when new code is deployed in to your Dev environment.

  1. Install the hello-world.sh script to run on code deployments to Dev. This example assumes your Dev environment is running the 'master' branch.

     cd /my/repo
     git checkout master
     cp hooks/samples/hello-world.sh hooks/dev/post-code-deploy
     git commit -a 'Run the hello-world script on post-code-deploy to Dev.'
     git push
    
  2. Visit the Workflow page in the Acquia Cloud UI. In the Dev environment, select the 'master' branch (if your Dev environment is already running master, select any other tag and then select master again), then press Deploy.

  3. Scroll down on the Workflow page. When the code deployment task is done, click its "Show" link to see the hook's output. It will look like this:

     Started
     Updating s1.dev to deploy master
     Deploying master on s1.dev
     [05:28:33] Starting hook: post-code-deploy
     Executing: /var/www/html/s1.dev/hooks/dev/post-code-deploy/hello-world.sh s1 dev master master [email protected]:s1.git git (as s1@srv-4)
     Hello, Cloud!
     [05:28:34] Finished hook: post-code-deploy
    

You can use the Code drop-down list to put your Dev environment back to whatever it was previously deploying.

The Cloud Hooks directory

The hooks directory in your repo has a directory structure like this:

/hooks / [env] / [hook] / [script]
  • [env] is a directory whose name is an environment name: 'dev' for Development, 'test' for Staging, and 'prod' for Production, as well as 'common' for all environments.

  • [hook] is a directory whose name is a Cloud Hook name: see below for supported hooks.

  • [script] is a program or shell script within the [env]/[hook] directory.

Each time a hookable action occurs, Acquia Cloud runs scripts from the directory common/[hook] and [target-env]/[hook]. All scripts in the hook directory are run, in lexicographical (shell glob) order. If one of the hook scripts exits with non-zero status, the remaining hook scripts are skipped, and the task is marked "failed" on the Workflow page so you know to check it. All stdout and stderr output from all the hooks that ran are displayed in the task log on the Workflow page.

Note that hook scripts must have the Unix "executable" bit in order to run. If your script has the execute bit set when you first add it to Git, you're all set. Otherwise, to set the execute bit to a file already in your Git repo:

chmod a+x ./my-hook.sh
git add ./my-hook.sh
git commit -m 'Add execute bit to my-hook.sh'
git push

Sample scripts

The samples directory contains bare-bones example scripts for each of the supported hooks, plus a variety of useful user-contributed scripts. Each script starts with comments explaining what it is for and how it works.

Sample scripts currently include:

  • post-code-deploy.tmpl: Template for post-code-deploy hook scripts.
  • 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.
  • update-db.sh: Run drush updatedb to perform database updates.
  • db-scrub.sh: Scrub important information from a Drupal database.
  • 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.

Supported hooks

This section defines the currently supported Cloud Hooks and the command-line arguments they receive.

post-code-deploy

The post-code-deploy hook is run whenever you use the Workflow page to deploy new code to an environment, either via drag-drop or by selecting an existing branch or tag from the Code drop-down list. (The post-code-update hook runs after every code commit.)

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

  • site: The site name. This is the same as the Acquia Cloud username for the site.
  • target-env: The environment to which code was just deployed.
  • source-branch: The code branch or tag being deployed. See below.
  • deployed-tag: The code branch or tag being deployed. See below.
  • repo-url: The URL of your code repository.
  • repo-type: The version control system your site is using; "git".

The meaning of source-branch and deployed-tag depends on whether you use drag-drop to move code from one environment to another or whether you select a new branch or tag for an environment from the Code drop-down list:

  • With drag-drop, the "source branch" is the branch or tag that the environment you dragged from is set to, and the "deployed tag" is the tag just deployed in the target environment. If source-branch is a branch (does not start with "tags/"), deployed-tag will be a newly created tag pointing at the tip of source-branch. If source-branch is a tag, deployed-tag will be the same tag.

  • With the Code drop-down list, source-branch and deployed-tag will both be the name of branch or tag selected from the drop-down list.

Example: If the Dev environment is deploying the master branch and you drag Dev code to Stage, the code-deploy arguments will be like:

post-code-deploy mysite test master tags/2011-11-05 [email protected]:mysite.git git

post-code-update

The post-code-update hook runs in response to code commits. When you push commits to a Git branch, the post-code-update hooks runs for each environment that is currently running that branch.

The arguments for post-code-update are the same as for post-code-deploy, with the source-branch and deployed-tag arguments both set to the name of the environment receiving the new code.

post-db-copy

The post-db-copy hook is run whenever you use the Workflow page to copy a database from one environment to another.

Usage: post-db-copy site target-env db-name source-env

  • site: The site name. This is the same as the Acquia Cloud username for the site.
  • target-env: The environment to which the database was copied.
  • db-name: The name of the database that was copied. See below.
  • source-env: The environment from which the database was copied.

db-name is not the actual MySQL database name but rather the common name for the database in all environments. Use the drush ah-sql-cli to connect to the actual MySQL database, or use the drush ah-sql-connect command to convert the site name and target environment into the specific MySQL database name and credentials. (The drush sql-cli and sql-connect commands work too, but only if your Drupal installation is set up correctly.)

Example: To "scrub" your production database by removing all user accounts every time it is copied into your Stage environment, put this script into /hooks/test/post-db-copy/delete-users.sh:

#!/bin/bash
site=$1
env=$2
db=$3
echo "DELETE FROM users" | drush @$site.$env ah-sql-cli --db=$db

post-files-copy

The post-files-copy hook is run whenever you use the Workflow page to copy the user-uploaded files directory from one environment to another.

Usage: post-files-copy site target-env source-env

  • site: The site name. This is the same as the Acquia Cloud username for the site.
  • target-env: The environment to which files were copied.
  • source-env: The environment from which the files were copied.

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

More Repositories

1

blt

Acquia's toolset for automating Drupal 10 development, testing, and deployment.
PHP
435
star
2

reservoir

A back end for your front end: a content repository. Powered by Drupal 8, JSON API and OAuth2.
244
star
3

waterwheel.js

A generic JavaScript helper library to query and manipulate Drupal 8 via core REST and JSON API
232
star
4

lightning

Lightning was a base distribution for fast and feature-rich Drupal. Support ended on November 2, 2021 and it is no longer maintained.
PHP
188
star
5

drupal-spec-tool

A tool for specifying Drupal architecture details and generating automated tests for them.
Gherkin
146
star
6

lightning-project

A Composer-based installer for the Lightning distribution of Drupal 8. Support ended on November 2, 2021 and this project is no longer maintained.
133
star
7

statsgod

A Statsd implementation written in GO lang
Go
119
star
8

drupal-create

Drupal Create - an iOS mobile app
Objective-C
85
star
9

http-hmac-spec

An HMAC message format for securing RESTful web APIs.
78
star
10

commons

Project is hosted on drupal.org/project/commons. Mirrored here for Travis CI-integration.
PHP
68
star
11

headless_lightning

A more opinionated flavor of Lightning for building decoupled applications. Support ended on November 2, 2021 and this project is no longer maintained.
PHP
58
star
12

http-hmac-php

An implementation of the HTTP HMAC Spec in PHP that integrates with popular libraries such as Symfony and Guzzle.
PHP
52
star
13

moonshot

Moonshot: Because releasing services shouldn't be a moonshot!
Ruby
50
star
14

http-hmac-postman

A postman prescript for connecting to HMAC protected API's
JavaScript
43
star
15

cli

Command-line interface for Acquia Cloud Platform products
PHP
42
star
16

mc-cs-plugin-custom-objects

Mautic plugin adding Custom Objects feature
PHP
39
star
17

pipelines-examples

Pipelines examples build files
37
star
18

acquia_cms

Low or no-code site building for Drupal within the Acquia Platform.
PHP
29
star
19

acf

Acquia Commerce Framework - a lightweight reference framework for headless e-commerce with Drupal.
JavaScript
29
star
20

reservoir-project

A Composer-based installer for the Reservoir distribution of Drupal 8.
27
star
21

acquia-sdk-php

The Acquia SDK for PHP allows developers to build applications on top of Acquia services.
PHP
27
star
22

orca

A tool for testing a company's software packages together in the context of a realistic, functioning, best practices Drupal build
PHP
26
star
23

aws-proxy

A reverse proxy to Amazon web services
Go
25
star
24

logstream

Stream logs from Acquia Cloud.
Ruby
24
star
25

drupal-recommended-project

Recommended Drupal project for use on Acquia Cloud
23
star
26

acsf-tools

Command line tools for working with Acquia Cloud Site Factory
PHP
20
star
27

next-acms

ACMS with fully or progressively decoupled front-end
TypeScript
19
star
28

coding-standards-php

PHP_CodeSniffer rules (sniffs) for Acquia coding standards
19
star
29

cohesion

Cohesion redefines what it takes to create beautiful websites. Cohesion is a low-code, Drupal add-on available for Acquia customers.
PHP
19
star
30

df

Demo Framework - mirrored at https://git.drupal.org/project/df.git
PHP
18
star
31

acquia-migrate-accelerate

An enhanced UI and assistant for Drupal migrations.
PHP
13
star
32

graphite-cassandra-plugin

A backend plugin for Graphite
Python
12
star
33

training

Training code resources for Acquia and its Partners
PHP
12
star
34

content-hub-php

A PHP Client library to consume the Acquia Content Hub API.
PHP
11
star
35

lightning-features

Decoupled components used by the Lightning distribution for Drupal. – Mirror of
PHP
11
star
36

club

Command Line Utility for BLT
PHP
11
star
37

df-project

A Composer-based installer for the Demo Framework Drupal distribution
10
star
38

acquia-cms-project

A Composer project template for building sites with Acquia CMS.
Shell
10
star
39

drupal-environment-detector

Provides common methods for detecting the current Acquia environment
PHP
10
star
40

http-hmac-go

An implementation of the HTTP HMAC Spec in Golang.
Go
10
star
41

fifo2kinesis

Continuously reads data from a named pipe and publishes it to a Kinesis stream.
Go
10
star
42

blt-project

Composer-based installer for a Drupal 8 project utilizing BLT (READ-ONLY SUBTREE SPLIT)
PHP
9
star
43

acquia-ra-composer

Example composer.json and repo architecture that works with Remote Administrations Acquia Automation.
8
star
44

http-hmac-java

An implementation of the HTTP HMAC Spec in Java.
Java
7
star
45

logstream-chrome

Allows you to see what logs are being generated in real time as you browse around a website that you maintain on Acquia Cloud
JavaScript
7
star
46

decoupled-drupal

Example decoupled Druapl architecture intended to work along with acquia/decoupled-js
PHP
6
star
47

lift-sdk-php

Acquia Lift SDK for PHP -- [Created 2016-08-17 by nickveenhof aka [email protected] via github.acquia.com]
PHP
6
star
48

acquia-cms-starterkit

Provide Starter kits for Acquia CMS.
PHP
6
star
49

decoupled-js

Example decoupled JavaScript application intended to work along with acquia/decoupled-drupal
JavaScript
6
star
50

mc-cs-plugin-slooce

Slooce SMS Transport for Mautic
PHP
5
star
51

microbus

Turn a Rubygem into a package for deployment, including native gems.
Ruby
4
star
52

lightning-dev

Development tools for working on the Lightning distribution and its components.
PHP
4
star
53

contenthub-console

A package providing Acquia ContentHub commands for the CommonConsole command line interface.
PHP
4
star
54

acquia_lift

Mirror of the drupal.org repository for Acquia Lift module
PHP
4
star
55

cohesion-theme

Acquia Cohesion minimal theme. A Cohesion enabled kickstarter theme for use within Cohesion projects.
Twig
4
star
56

commons3

A github mirror for travis-ci integration
PHP
4
star
57

drupal-recommended-settings

The composer plugin to add Acquia's drupal recommended settings in your drupal project.
PHP
4
star
58

drupal-canary-project

Canary / reference Drupal application
PHP
3
star
59

layout

A clone of http://drupal.org/project/layout intended for demonstration
JavaScript
3
star
60

ember-logging-service

A generic ember logging service
JavaScript
3
star
61

DevDesktopCommon

Roff
3
star
62

blt-phpcs

Acquia BLT PHPCS plugin
PHP
3
star
63

http-hmac-javascript

An implementation of the HTTP HMAC Spec in JavaScript. -- [Created 2016-01-12 by ynx aka [email protected] via github.acquia.com]
JavaScript
3
star
64

http-hmac-ruby

An implementation of the HTTP HMAC Spec in ruby.
Ruby
3
star
65

memcache-settings

Recommended default Memcache settings for use with Acquia Cloud hosting.
PHP
3
star
66

hmac-request

An implementation of the HTTP HMAC Spec in PHP that integrates with popular libraries such as Symfony and Guzzle.
PHP
3
star
67

acquia-search-proxy

A web service proxy for the Acquia Search service
PHP
3
star
68

blt-launcher

Provides a BLT executable for your global PATH
PHP
3
star
69

pingdom-api

A PHP library for interacting with the Pingdom REST API.
PHP
3
star
70

mc-cs-plugin-vtiger

Enables VTiger CRM integration
PHP
3
star
71

blt-drupal-test

BLT Plugin for Drupal core and contributed testing
PHP
3
star
72

acquia_commercemanager

The Acquia Commerce Manager Drupal module enables site builders to use tools and templates in Drupal to rapidly build commerce experiences. It connects Drupal sites to Acquia's Commerce Connector Service leveraging eCommerce systems as the source of truth for eCommerce data in these experiences.
PHP
3
star
73

flightpath-cli

Get insight into your Drupal 7 migration to Drupal 9 (or later) powered by Acquia Migrate Accelerate.
PHP
3
star
74

zendesk-api

A PHP library for interacting with the Zendesk REST API.
PHP
3
star
75

acquia-lift-gtm

Google Tag Manager (GTM) template which allows customers to easily install and use Lift on their site via GTM.
Smarty
3
star
76

contenthub-console-helpers

A set of helper classes and traits for tasks common to console components.
PHP
2
star
77

blt-vm

Acquia BLT plugin providing support for Drupal VM
PHP
2
star
78

acquia-lift-samples

This provides sample code and examples of how to use the Lift API and SDK. This is for reference only, and is not intended to be used on a production site.
PHP
2
star
79

blt-travis

Travis CI integration for Acquia BLT
Shell
2
star
80

AD-Pressflow

Acquia-Drupal on Pressflow
PHP
2
star
81

acsf-contenthub-console

A package providing Acquia Cloud Site Factory commands for the CommonConsole command line interface.
PHP
2
star
82

drupal-minimal-project

Minimal Drupal project for use on Acquia Cloud
2
star
83

blt-require-dev

This package is used as a wrapper to include BLT's dev requirements. READ-ONLY SUBTREE SPLIT
2
star
84

mc-cf-mega-openapi-php-sdk

PHP SDK for MEGA's OpenAPI
PHP
2
star
85

carbon-cassandra-plugin

A backend plugin for Megacarbon to talk with Cassandra
Python
2
star
86

apidoc-openapi-3

NodeJs (npm) tool to convert apidoc to OpenAPI 3.0 spec. (inspired by apidoc-swagger-3)
JavaScript
2
star
87

pipelines-ci-public

Public repo used for public forks behaviour testing by the pipelines team -- [Created 2017-01-31 by marcingy aka [email protected] via github.acquia.com]
2
star
88

acquia-search-service-client-php

A Client Library for the Acquia Search Service API
PHP
2
star
89

ember-http-hmac

An Ember addon utilizing the http-hmac-javascript library to automatically sign Ajax requests either standalone and through ember-data
JavaScript
2
star
90

gsuite-sso

Public hosting of our Google Suite SSO information. -- [Created 2018-02-02 by Zlender aka [email protected] via github.acquia.com]
2
star
91

nessus-client

Ruby library and simple cli tool for interacting with the Nessus 6 REST API https://cloud.tenable.com/api#/ -- [Created 2016-03-18 by pwolanin aka [email protected] via github.acquia.com]
Ruby
2
star
92

fluent-plugin-sumologic-cloud-syslog

Fluentd plugin to send logs to the Sumologic cloud syslog collectors
Ruby
2
star
93

pyplexus

Python based command line interface tool for plexus. -- [Created 2019-08-21 by jfarrell aka [email protected] via github.acquia.com]
1
star
94

d8

Drupal 8 hackathon work
PHP
1
star
95

blt-tugboat

Acquia BLT Tugboat integration
PHP
1
star
96

collectd-traefik

Collectd plugin to report metrics for Traefik
Python
1
star
97

acquia_claro

A clean, accessible, and powerful Drupal administration theme.
SCSS
1
star
98

acquia-sdk-php-cloud-db

[READ ONLY] Subtree split of the Acquia Cloud Database component
PHP
1
star
99

acquia_cms_page

Unstructured Page content type and related configuration for Acquia CMS.
PHP
1
star
100

acquia_cms_place

Place content type and related configuration for Acquia CMS.
PHP
1
star