Skip to content

Instantly share code, notes, and snippets.

@tobybellwood
Last active December 11, 2019 20:41
Show Gist options
  • Save tobybellwood/3c50bab5649745c6211a476df449440f to your computer and use it in GitHub Desktop.
Save tobybellwood/3c50bab5649745c6211a476df449440f to your computer and use it in GitHub Desktop.
sample expanded .lagoon.yml (E&OE)
docker-compose-yaml: docker-compose.yml
project: XXXXXXXXX
tasks:
pre-rollout:
tasks:
pre-rollout:
- run:
name: Set backup and config dirs as env vars
command: |
export BACKUP_DIR="/app/web/sites/default/files/private/backups" && mkdir -p "$BACKUP_DIR"
service: cli
shell: bash
- run:
name: Snapshot the database and store
command: |
if [[ "$LAGOON_ENVIRONMENT_TYPE" = "production" ]]; then drush sql:dump --root=/app --gzip --result-file="$BACKUP_DIR"/pre-deploy-dump.sql; fi
service: cli
shell: bash
- run:
name: Snapshot the config and store
command: |
drush config:export --root=/app sync -y --destination "$BACKUP_DIR"/config && tar -czf "$BACKUP_DIR"/pre-deploy-config.tar.gz "$BACKUP_DIR"/config --remove-files
service: cli
shell: bash
post-rollout:
- run:
name: If no Drupal installed and not master branch, sync from master branch
command: |
if tables=$(drush sqlq 'show tables;') && [ -z "$tables" ] && [[ "$LAGOON_GIT_BRANCH" != "master" ]]; then
# no drupal installed, sync DB from master branch
drush sql-sync @govcms.prod @self -y
fi
service: cli
shell: bash
# - run:
# name: Uncomment this section to enable Config Management
# command: |
# if [[ "$LAGOON_GIT_BRANCH" != "master" ]]; then
# drush cim -y sync
# else
# drush cim -y dev --partial
# fi
# service: cli
# shell: bash
- run:
name: drush updb
command: drush -y updb
service: cli
- run:
name: drush cr
command: drush -y cr
service: cli
- run:
name: ensure govcms/lagoon modules are enabled
command: drush en -y govcms_lagoon && drush pmu -y govcms_lagoon
service: cli
- run:
name: enable stage_file_proxy on non-master environments
command: |
if [[ "$LAGOON_GIT_BRANCH" != "master" ]]; then
drush en stage_file_proxy -y
fi
service: cli
- run:
name: If post-rollout is successful on master branch, replace 'last-good' backup
command: |
if [[ "$LAGOON_GIT_BRANCH" = "master" ]]; then
mv -u /app/web/sites/default/files/private/backups/pre-deploy-dump.sql.gz /app/web/sites/default/files/private/backups/pre-deploy-dump-last-good.sql.gz
fi
service: cli
shell: bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment