-
Notifications
You must be signed in to change notification settings - Fork 14
/
.lagoon.yml
169 lines (148 loc) · 6.36 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
159
160
161
162
163
164
165
166
167
168
169
docker-compose-yaml: docker-compose.yml
project: dpl-cms-core
ssh: 20.238.147.183:22
api: https://api.lagoon.dplplat01.dpl.reload.dk/graphql
environment_variables:
git_sha: 'true'
tasks:
post-rollout:
- run:
name: Create new GH deployment
command: |
GH_DEPLOYMENTS=$(curl -H "Authorization: Bearer $GH_DEPLOYMENT_TOKEN" \
"https://api.github.com/repos/danskernesdigitalebibliotek/dpl-cms/deployments?ref=$LAGOON_PR_HEAD_BRANCH&environment=$LAGOON_ENVIRONMENT")
GH_DEPLOYMENT_ID=$(echo "$GH_DEPLOYMENTS" | grep '"id":' | head -n 1 | sed 's/[^0-9]*\([0-9]*\).*/\1/')
echo "$GH_DEPLOYMENTS"
echo "Found GH deployment with ID '$GH_DEPLOYMENT_ID'"
# The only way to keep a value between tasks, is saving it in a
# file. Environment variables are killed between tasks, apart from
# the global ones.
echo "$GH_DEPLOYMENT_ID" > /tmp/GH_DEPLOYMENT_ID
LAGOON_DEPLOYS_LOG_URL="https://ui.lagoon.dplplat01.dpl.reload.dk/projects/$LAGOON_PROJECT/dpl-cms-$LAGOON_ENVIRONMENT/deployments"
echo "$LAGOON_DEPLOYS_LOG_URL" > /tmp/LAGOON_DEPLOYS_LOG_URL
echo "Creating a initial pending deployment status."
./dev-scripts/lagoon-set-gh-deploy-status.sh "in_progress"
service: cli
- run:
name: If drupal is not installed
command: |
source dev-scripts/lagoon-error-handling.sh
if tables=$(drush sqlq "show tables like 'node';") && [ -z "$tables" ]; then
# Install and set the admin password to a Lagoon variable if it exists.
if [[ -n $PR_DRUPAL_PWD ]]; then
drush si --existing-config -y --account-pass=$PR_DRUPAL_PWD
else
# Otherwise install and let drush generate a password.
drush si --existing-config -y
fi
# Practice shows that the cache needs to be cleared to avoid
# configuration errors even after a site install.
drush cr
fi
service: cli
shell: bash
- run:
name: drush deploy
command: |
source dev-scripts/lagoon-error-handling.sh
if [[ -f config/sync/system.site.yml ]]; then
echo "Config detected, doing a drush deploy"
drush deploy
# Purge all varnish cache to make sure
# that new changes will come through
# eg. js assets.
echo "...and clearing the external cache."
drush cache:rebuild-external -y || true
else
echo "No config detected, clearing cache"
drush cr
fi
service: cli
- run:
# We need this because if we create the directory before volume mount
# it will be gone.
name: Create module upload directory in public files
command: |
source dev-scripts/lagoon-error-handling.sh
if [[ ! -d "web/sites/default/files/modules_local" ]]; then
echo "Creating directory for module uploads"
mkdir web/sites/default/files/modules_local
fi
service: cli
- run:
name: Import translations
command: |
source dev-scripts/lagoon-error-handling.sh
drush locale-check
drush locale-update
service: cli
- run:
name: Create test users
command: |
source dev-scripts/lagoon-error-handling.sh
# Only create test users if they do not exist already.
if editor_user=$(drush sqlq 'select * from users_field_data where name = "editor"') && [ -z "$editor_user" ]; then
drush user:create editor --password="$PR_DRUPAL_PWD"
drush user:role:add 'editor' editor
drush user:create administrator --password="$PR_DRUPAL_PWD"
drush user:role:add 'administrator' administrator
drush user:create mediator --password="$PR_DRUPAL_PWD"
drush user:role:add 'mediator' mediator
drush user:create local_administrator --password="$PR_DRUPAL_PWD"
drush user:role:add 'local_administrator' local_administrator
drush user:create patron --password="$PR_DRUPAL_PWD"
drush user:role:add 'patron' patron
drush user:create $GRAPHQL_USER_NAME --password="$GRAPHQL_USER_PASSWORD"
drush user:role:add 'external_system' $GRAPHQL_USER_NAME
drush user:role:add 'graphql_consumer' $GRAPHQL_USER_NAME
else
echo "Test users already exist. Skipping creation..."
fi
service: cli
- run:
name: Enable example content
command: |
source dev-scripts/lagoon-error-handling.sh
drush en -y dpl_example_content
service: cli
- run:
name: Setting Deployment status success
command: |
DRUPAL_URL=$(drush browse)
./dev-scripts/lagoon-set-gh-deploy-status.sh "success" "$DRUPAL_URL"
service: cli
environments:
main:
cronjobs:
- name: drush cron
schedule: "M/15 * * * *"
command: drush cron
service: cli
- name: import translations
# TODO Consider if translation checking frequency should be reduced.
# A high frequency is used to ensure quick turnaround time during
# development. Updating (or checking) translations could have side effects on
# caching etc. and once things have settled down a lower frequency may be
# more appropriate.
schedule: "M/30 * * * *"
command: drush locale-check && drush locale-update
service: cli
- name: import danish config translations
schedule: "M/30 * * * *"
command: drush dpl_po:import-remote-config-po da https://danskernesdigitalebibliotek.github.io/dpl-cms/translations/da.config.po
service: cli
pr-1501:
cronjobs:
- name: drush cron
schedule: "M/15 * * * *"
command: drush cron
service: cli
- name: import translations
# Quite frequent translation import because of businezz.
schedule: "M/30 * * * *"
command: drush locale-check && drush locale-update
service: cli
- name: import danish config translations
schedule: "M/30 * * * *"
command: drush dpl_po:import-remote-config-po da https://danskernesdigitalebibliotek.github.io/dpl-cms/translations/da.config.po
service: cli