forked from civictheme/monorepo-drupal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.lagoon.yml
158 lines (140 loc) · 6.25 KB
/
.lagoon.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
docker-compose-yaml: docker-compose.yml
# Inject the deployed Git SHA.
environment_variables:
git_sha: 'true'
# Uncomment below to login into container registries if using private images.
# container-registries:
# dockerhub:
# username: <dockerhub username>
# # Environment variable $DREVOPS_DOCKER_REGISTRY_TOKEN with Docker registry
# # password is injected into container via LagoonCLI.
# # @see https://docs.lagoon.sh/using-lagoon-advanced/environment-variables/#runtime-environment-variables-lagoon-api
# password: DREVOPS_DOCKER_REGISTRY_TOKEN
tasks:
post-rollout:
- run:
name: Show DrevOps variables.
command: |
env -0 | sort -z | tr '\0' '\n' | grep ^DREVOPS_
service: cli
shell: bash
- run:
name: Replace app entrypoint to prevent probes from bootstrapping
command: |
mv /app/docroot/index.php /tmp/index.php
echo "<? exit('ok');" >> /app/docroot/index.php
service: nginx-php
container: php
- run:
name: Set GitHub deployment status
command: |
if [ -n "${DREVOPS_NOTIFY_GITHUB_TOKEN}" ] && [ -n "$LAGOON_PR_NUMBER" ]; then
[ -n "$LAGOON_PR_NUMBER" ] && GIT_SHA=${LAGOON_PR_HEAD_SHA#origin/} || GIT_SHA=$LAGOON_GIT_SHA
DREVOPS_NOTIFY_DEPLOY_REPOSITORY="salsadigitalauorg/civictheme_source" \
DREVOPS_NOTIFY_DEPLOY_REF="$GIT_SHA" \
DREVOPS_NOTIFY_DEPLOY_GITHUB_OPERATION="start" \
./scripts/drevops/notify-deployment-github.sh || true
fi
service: cli
shell: bash
- run:
name: Backup DB before deployment in production
command: |
if [ "$LAGOON_ENVIRONMENT_TYPE" = "production" ] || [ "$LAGOON_GIT_BRANCH" = "${DREVOPS_PRODUCTION_BRANCH:-main}" ]; then
echo "==> Running in PRODUCTION environment."
DREVOPS_DB_DIR=/app/docroot/sites/default/files/private/pre_deployment_backups ./scripts/drevops/export-db-file.sh
fi
service: cli
- run:
name: Install site
command: |
# Read DB dump from the temp location instead of '.data'.
export DREVOPS_DB_DIR=/tmp/data
# Deployments from UI are not able to bypass the value of
# DREVOPS_DRUPAL_INSTALL_OVERRIDE_EXISTING_DB set by the deploy-lagoon.sh
# during previous deployments (it sets value to '0' to mitigate Lagoon bug
# where environment variables cannot be deleted and have to be set to a value).
# @see https://github.com/uselagoon/lagoon/issues/1922
# Explicitly set DB overwrite flag to the value from .env file for
# deployments from the profile.
if [ "$DREVOPS_DRUPAL_INSTALL_FROM_PROFILE" = "1" ]; then
export DREVOPS_DRUPAL_INSTALL_OVERRIDE_EXISTING_DB="$(cat .env | grep ^DREVOPS_DRUPAL_INSTALL_OVERRIDE_EXISTING_DB | cut -c45-)"
fi
if [ "$LAGOON_ENVIRONMENT_TYPE" = "production" ] || [ "$LAGOON_GIT_BRANCH" = "${DREVOPS_PRODUCTION_BRANCH:-main}" ]; then
echo "==> Running in PRODUCTION environment."
# Never unblock admin user in production.
export DREVOPS_DRUPAL_LOGIN_UNBLOCK_ADMIN=0
# Never sanitize DB.
export DREVOPS_DRUPAL_INSTALL_DB_SANITIZE_SKIP=1
fi
# Install site.
./scripts/drevops/drupal-install-site.sh
service: cli
shell: bash
- run:
name: Restore app entrypoint
command: |
rm /app/docroot/index.php
mv /tmp/index.php /app/docroot/index.php
service: nginx-php
container: php
- run:
name: Send deployment notifications
command: |
[ -n "$LAGOON_PR_NUMBER" ] && GIT_REF=$LAGOON_PR_NUMBER || GIT_REF=$LAGOON_GIT_BRANCH
php ./scripts/drevops/notify-deployment-email.php \
"CivicTheme Source" \
"[email protected]|CivicTheme group" \
"$GIT_REF" \
"$LAGOON_ROUTES"
if [ -n "$NEWRELIC_ENABLED" ] && [ -n "$NEWRELIC_LICENSE" ] && [ -n "$DREVOPS_NOTIFY_NEWRELIC_APIKEY" ]; then
[ -n "$LAGOON_PR_NUMBER" ] && GIT_SHA=${LAGOON_PR_HEAD_SHA#origin/} || GIT_SHA=$LAGOON_GIT_SHA
DREVOPS_NOTIFY_NEWRELIC_APP_NAME="$LAGOON_PROJECT-$GIT_SHA" \
DREVOPS_NOTIFY_DEPLOY_REF="$GIT_SHA" \
./scripts/drevops/notify-deployment-newrelic.sh
fi
if [ -n "${DREVOPS_NOTIFY_GITHUB_TOKEN}" ] && [ -n "$LAGOON_PR_NUMBER" ]; then
[ -n "$LAGOON_PR_NUMBER" ] && GIT_SHA=${LAGOON_PR_HEAD_SHA#origin/} || GIT_SHA=$LAGOON_GIT_SHA
DREVOPS_NOTIFY_DEPLOY_REPOSITORY="salsadigitalauorg/civictheme_source" \
DREVOPS_NOTIFY_DEPLOY_REF="$GIT_SHA" \
DREVOPS_NOTIFY_DEPLOY_ENVIRONMENT_URL="$LAGOON_ROUTE" \
DREVOPS_NOTIFY_DEPLOY_GITHUB_OPERATION="finish" \
./scripts/drevops/notify-deployment-github.sh || true
fi
if [ -n "${DREVOPS_NOTIFY_DEPLOY_JIRA_USER}" ] && [ -n "${DREVOPS_NOTIFY_DEPLOY_JIRA_TOKEN}" ]; then
[ -n "$LAGOON_PR_NUMBER" ] && GIT_BRANCH=$LAGOON_PR_HEAD_BRANCH || GIT_BRANCH=$LAGOON_GIT_BRANCH
DREVOPS_NOTIFY_JIRA_ENDPOINT="${DREVOPS_NOTIFY_JIRA_ENDPOINT:-https://jira.atlassian.com}" \
DREVOPS_NOTIFY_DEPLOY_BRANCH="$GIT_BRANCH" \
DREVOPS_NOTIFY_DEPLOY_ENVIRONMENT_URL="$LAGOON_ROUTE" \
./scripts/drevops/notify-deployment-jira.sh || true
fi
service: cli
shell: bash
environments:
# Branch name that represents production environment.
master:
cronjobs:
- name: drush cron
schedule: '*/15 * * * *'
command: drush cron --root=/app
service: cli
routes:
- nginx-php:
- default.civictheme.io
monitoring_urls:
- default.civictheme.io
# Branch name that represents development environment.
develop:
cronjobs:
- name: drush cron
schedule: '*/15 * * * *'
command: drush cron --root=/app
service: cli
routes:
- nginx-php:
- defaultdev.civictheme.io
monitoring_urls:
- defaultdev.civictheme.io
routes:
insecure: Redirect