-
Notifications
You must be signed in to change notification settings - Fork 0
229 lines (199 loc) · 7.38 KB
/
drupal-update.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
name: Update drupal project
on:
workflow_call:
inputs:
drupal-install-profile:
description: The install profile to use when installing Drupal
required: false
type: string
default: minimal
drupal-web-root:
description: The web root (relative to the workspace root)
required: false
type: string
default: web
drupal-config-path:
description: The config sync path (relative to the web root)
required: false
type: string
default: ../config/sync
drupal-extra-settings:
description: Extra settings to add to settings.php. Do not include opening php tag.
required: false
type: string
default: ''
php-version:
description: The PHP version to run on
required: false
type: string
default: 8.1
branch:
description: The branch to check for updates, defaults to the default branch
required: false
type: string
default: master
repman-host:
description: The repman host for composer, if applicable
required: false
type: string
use-existing-config:
description: >
Drupal install profiles with a hook_install cannot be installed with
the --existing-config flag. You can set this parameter to disable it,
defaults to true (enabled).
required: false
type: boolean
default: true
secrets:
repository_token:
required: true
composer_repman_token:
required: false
composer_github_token:
required: false
jobs:
update_drupal:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
fetch-depth: 0
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- name: 'Get next minor version'
id: semvers
uses: "WyriHaximus/github-action-next-semvers@v1"
with:
version: ${{ steps.previoustag.outputs.tag }}
- name: Set composer auth JSON
id: auth-json
if: inputs.repman-host != ''
run: |
echo "auth_json={\"http-basic\":{\"${{ inputs.repman-host }}\":{\"username\": \"token\", \"password\": \"${{ secrets.composer_repman_token }}\"}}}" >> $GITHUB_OUTPUT
- name: Setup PHP and composer
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
extensions: date, dom, filter, gd, hash, json, pcre, pdo, session, simplexml, spl, tokenizer, xml
env:
GITHUB_TOKEN: ${{ secrets.composer_github_token }}
COMPOSER_AUTH_JSON: |
${{ steps.auth-json.outputs.auth_json }}
- name: Shutdown Ubuntu MySQL (SUDO)
run: sudo service mysql stop
- name: Setup MySQL
uses: mirromutth/[email protected]
with:
host port: 3306
mysql version: 8.0
mysql database: drupal
mysql user: drupal
mysql password: drupal
- name: Create settings.php
uses: DamianReeves/write-file-action@master
with:
path: ${{ github.workspace }}/${{ inputs.drupal-web-root }}/sites/default/settings.php
contents: |
<?php
$databases = [];
$databases['default']['default'] = [
'database' => 'drupal',
'username' => 'drupal',
'password' => 'drupal',
'host' => '127.0.0.1',
'port' => '3306',
'driver' => 'mysql',
'prefix' => '',
'collation' => 'utf8mb4_general_ci',
];
$settings['config_sync_directory'] = '${{ inputs.drupal-config-path }}';
$settings['hash_salt'] = '${{ github.sha }}';
$settings['update_free_access'] = FALSE;
$settings['container_yamls'][] = $app_root . '/' . $site_path . '/services.yml';
$settings['file_scan_ignore_directories'] = [
'node_modules',
'bower_components',
];
$settings['entity_update_batch_size'] = 50;
$settings['entity_update_backup'] = TRUE;
$settings['migrate_node_migrate_type_classic'] = FALSE;
${{ inputs.drupal-extra-settings }}
write-mode: overwrite
- name: Composer install
run: composer install --no-scripts
- name: Install Drupal
run: vendor/bin/robo digipolis:install-drupal8 ${{ inputs.drupal-install-profile }} --force ${{ inputs.use-existing-config && '--existing-config' || '' }} --config-import
- name: Execute config import
run: vendor/bin/drush cim -y
- name: Update composer dependencies
id: composer-update
run: |
echo "Running composer update..."
composer_exit_code=0
output=$(composer update --no-scripts 2>&1 || composer_exit_code=1)
# If composer update fails, exit with a non-zero status
if [ $composer_exit_code -ne 0 ]; then
echo "Composer update failed"
echo "$output"
exit $composer_exit_code
fi
echo "✓ Composer update successful"
echo "$output"
# Process output if successful
echo "commit_body<<EOF" >> $GITHUB_OUTPUT
echo "$output" | grep -Pzo 'Lock file operations.*(\n|.)*Writing lock file' | tail -n +2 | head -n -1 | sed -r 's/ +?- ([^ ]+) //g' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: "Run composer normalize"
id: composer-normalize
run: 'composer normalize --no-scripts'
- name: Run Drupal updates
run: vendor/bin/drush updb -y
- name: Export config after updates
run: vendor/bin/drush cex -y
- name: Generate composer diff
id: composer-diff
uses: IonBazan/composer-diff-action@v1
with:
base: ${{ github.sha }}
with-links: true
- name: Check for GrumPHP
id: check_grumphp
uses: andstor/file-existence-action@v2
with:
files: "vendor/bin/grumphp"
- name: Remove git commit hooks
if: steps.check_grumphp.outputs.files_exists == 'true'
run: vendor/bin/grumphp git:deinit
- name: Create a pull request
uses: peter-evans/create-pull-request@v6
id: cpr
with:
token: ${{ secrets.repository_token }}
commit-message: |
Update modules
${{ steps.composer-update.outputs.commit_body }}
signoff: false
branch: hotfix/${{ steps.semvers.outputs.patch }}
base: ${{ inputs.branch }}
delete-branch: false
title: Update modules
body: |
${{ steps.composer-update.outputs.commit_body }}
labels: |
updates
automated pr
draft: true
- name: Add composer.lock diff as PR comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.cpr.outputs.pull-request-number }}
with:
header: composer-diff
number: ${{ steps.cpr.outputs.pull-request-number }}
message: |
<details>
<summary>Composer package changes</summary>
${{ steps.composer-diff.outputs.composer_diff }}
</details>