forked from os2loop/os2loop
-
Notifications
You must be signed in to change notification settings - Fork 1
153 lines (125 loc) · 5.07 KB
/
Copy pathsite.yaml
File metadata and controls
153 lines (125 loc) · 5.07 KB
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
# Do not edit this file! Make a pull request on changing
# github/workflows/drupal/site.yaml in
# https://github.com/itk-dev/devops_itkdev-docker if need be.
### ### Drupal
###
### Checks that site can be installed and can be updated (from base branch on
### pull request).
###
### #### Assumptions
###
### 1. A docker compose service named `phpfpm` can be run and `composer` can be
### run inside the `phpfpm` service.
### 2. The docker setup contains a database container and other the dependent
### services and the default settings match connection credentials for these
### services.
### 3. The Drupal site can be installed from existing config.
name: Drupal
env:
COMPOSE_USER: runner
on:
pull_request:
push:
branches:
- main
- develop
jobs:
install-site:
name: Check that site can be installed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Create docker network
run: |
docker network create frontend
- name: Start docker and install dependencies
run: |
docker compose pull
docker compose up --detach
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
docker compose exec phpfpm composer install --no-interaction
- name: Install site
run: |
# Add some local settings.
cat > web/sites/default/settings.local.php <<'EOF'
<?php
$settings['hash_salt'] = '${{ github.head_ref }}';
EOF
# Install the site from config
docker compose exec phpfpm vendor/bin/drush site:install --existing-config --yes
- name: Show site URL
run: |
echo $(docker compose exec phpfpm vendor/bin/drush --uri=http://$(docker compose port nginx 8080) user:login)
update-site:
# Check updating site only on pull request.
if: github.event_name == 'pull_request'
name: Check that site can be updated
# This job checks that the Drupal site can be upgraded without issues.
#
# We do this by
#
# 1. Checking out the base branch ("github.base_ref") and installing the
# site from scratch (using the exact same steps as the "install-site"
# job)
# 2. Checking out the updated code and updating the site from the previous
# installation
#
# Notice that step 2 is NOT run with the code in our new branch, but with
# the updated code merged on top of the target branch
# (cf.https://github.com/actions/checkout/issues/881). This makes sure that
# we can actually update the site after merging with the base branch.
#
# In some cases we run into a situation where the base site (step 1) cannot
# be installed, e.g. if this is a new project or we're making changes that
# require manual steps on the upgrade path, and then this jobs will fail. In
# that case we should note this in the pull request description and document
# the steps needed to complete the upgrade path.
runs-on: ubuntu-latest
steps:
# Install site from our base ref
- uses: actions/checkout@v5
with:
ref: ${{ github.base_ref }}
- name: Create docker network
run: |
docker network create frontend
- name: Start docker and install dependencies
run: |
docker compose pull
docker compose up --detach
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
docker compose exec phpfpm composer install --no-interaction
- name: Install site
run: |
# Add some local settings.
cat > web/sites/default/settings.local.php <<'EOF'
<?php
$settings['hash_salt'] = '${{ github.head_ref }}';
EOF
# Install the site from config
docker compose exec phpfpm vendor/bin/drush site:install --existing-config --yes
- name: Show site URL
run: |
echo $(docker compose exec phpfpm vendor/bin/drush --uri=http://$(docker compose port nginx 8080) user:login)
- name: Clean up root stuff
run: |
sudo chown -Rv $USER:$USER vendor/ web/ private-files/ || true
sudo chmod -Rv a+w web/sites/default || true
# Update site using our updated code.
- uses: actions/checkout@v5
with:
# Keep our local settings (cf.
# https://github.com/actions/checkout?tab=readme-ov-file#usage)
clean: false
- name: Start docker and install dependencies
run: |
docker compose pull
docker compose up --detach
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
docker compose exec phpfpm composer install --no-interaction
- name: Update site
run: |
docker compose exec phpfpm vendor/bin/drush deploy --yes
- name: Show site URL
run: |
echo $(docker compose exec phpfpm vendor/bin/drush --uri=http://$(docker compose port nginx 8080) user:login)