Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Commit

Permalink
New lagoon.yml for pre/post rollout task split. (#33)
Browse files Browse the repository at this point in the history
* New lagoon.yml for pre/post rollout tasks
  • Loading branch information
Simon Hobbs authored and SRowlands committed Dec 16, 2019
1 parent 2baaad9 commit 9a0b55e
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .lagoon.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Do not remove. This location may be used by deployment scripts for database and config snapshots.
SNAPSHOTS=/app/web/sites/default/files/private/backups
79 changes: 71 additions & 8 deletions .lagoon.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,82 @@
docker-compose-yaml: docker-compose.yml

tasks:
post-rollout:
- run:
name: Deploy GovCMS
command: govcms-deploy
service: cli

environments:
master:
types:
mariadb: mariadb-shared

cronjobs:
- name: drush cron
schedule: "0 * * * *"
command: 'drush cron --root=/app'
service: cli

# Note regarding tasks in the scaffold.
# Please avoid making scripts more than one or two lines, and avoid if/else logic.
# When PaaS users or the support team modify this file, it should be easy to turn things on and off.

tasks:
pre-rollout:
- run:
name: Ensure backup folder exists - not all current envs have one
command: mkdir -p /app/web/sites/default/files/private/backups
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=/app/web/sites/default/files/private/backups/pre-deploy-dump.sql; fi
service: cli
shell: bash
- run:
name: Snapshot the config and store
command: if [[ $(drush cex --root=/app sync -y --quiet --destination "$TMP"/config; echo "$?") = 0 ]]; then tar -czf /app/web/sites/default/files/private/backups/pre-deploy-config.tar.gz "$TMP"/config --remove-files; fi
service: cli
shell: bash

post-rollout:
- run:
name: Correct legacy drush alias if necessary
command: sed -i "s/%%PROJECT_NAME%%/\${env.LAGOON_PROJECT}/g" /app/drush/sites/govcms.site.yml
service: cli
shell: bash
- run:
name: Ensure backup folder exists
command: mkdir -p /app/web/sites/default/files/private/backups
service: cli
shell: bash
- run:
name: If a new environment populate database from master
command: drush status db-status | grep Connected || if [[ "$LAGOON_ENVIRONMENT_TYPE" != "production" ]]; then drush sql:sync @govcms.prod @self -y; fi
service: cli
shell: bash
- run:
name: Perform database updates
command: drush -y updatedb
service: cli
shell: bash
- run:
name: Perform config import (uncomment to enable)
command: |
# drush cim -y sync && if [[ "$LAGOON_ENVIRONMENT_TYPE" != "production" ]]; then drush cim -y --partial --source=../config/dev; fi
service: cli
shell: bash
- run:
name: Perform cache rebuild
command: drush -y cr
service: cli
shell: bash
- run:
name: Ensure GovCMS/Lagoon modules are enabled
command: drush en -y govcms_lagoon && drush pmu -y govcms_lagoon
service: cli
shell: bash
- run:
name: Enable any non-production modules
command: if [[ "$LAGOON_ENVIRONMENT_TYPE" != "production" ]]; then drush en stage_file_proxy -y; fi
service: cli
shell: bash
- run:
name: Preserve the last successful backup
command: export BACKUP="/app/web/sites/default/files/private/backups/pre-deploy-dump" && mv "$BACKUP.sql.gz" "$BACKUP-last-good.sql.gz" || true
service: cli
shell: bash

0 comments on commit 9a0b55e

Please sign in to comment.