-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
252 lines (224 loc) · 7.72 KB
/
action.yml
File metadata and controls
252 lines (224 loc) · 7.72 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
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
name: Update drupal project
description: Updates drupal projects
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
repository_token:
required: true
composer_repman_token:
required: false
composer_github_token:
required: false
committer:
description: >
The committer name and email address in the format `Display Name <email@address.com>`.
Defaults to the GitHub Actions bot user.
required: false
type: string
default: ''
author:
description: >
The committer name and email address in the format `Display Name <email@address.com>`.
Defaults to the user who triggered the workflow run.
required: false
type: string
default: ''
runs:
using: 'composite'
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 != ''
shell: bash
run: |
echo "auth_json={\"http-basic\":{\"${{ inputs.repman-host }}\":{\"username\": \"token\", \"password\": \"${{ inputs.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, :redis
env:
GITHUB_TOKEN: ${{ inputs.composer_github_token }}
COMPOSER_AUTH_JSON: |
${{ steps.auth-json.outputs.auth_json }}
- name: Set up MySQL
shell: bash
run: |
sudo systemctl start mysql.service
until sudo mysqladmin ping --silent; do sleep 1; done
- name: Configure database
shell: bash
run: |
mysql -u root -proot <<EOF
CREATE DATABASE IF NOT EXISTS drupal;
CREATE USER IF NOT EXISTS 'drupal'@'%' IDENTIFIED BY 'drupal';
GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'%';
FLUSH PRIVILEGES;
EOF
- 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
shell: bash
run: composer install --no-scripts
- name: Install Drupal
shell: bash
run: vendor/bin/robo digipolis:install-drupal8 ${{ inputs.drupal-install-profile }} --force ${{ inputs.use-existing-config && '--existing-config' || '' }} --config-import
- name: Execute config import
shell: bash
run: vendor/bin/drush cim -y
- name: Update composer dependencies
id: composer-update
shell: bash
run: |
{
echo "composer_update<<EOF"
composer update --no-scripts 2>&1
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Parse commit body
id: commit-body
shell: bash
run: |
{
echo "commit_body<<EOF"
echo "${{ steps.composer-update.outputs.composer_update }}" | grep -Pzo '(Lock file operations.*(\n|.)*Writing lock file)|Nothing to modify in lock file' | tail -n +2 | head -n -1 | sed -r 's/ +?- ([^ ]+) //g'
echo "EOF"
} >> $GITHUB_OUTPUT
- name: "Run composer normalize"
id: composer-normalize
shell: bash
run: 'composer normalize --no-scripts'
- name: Run Drupal updates
shell: bash
run: vendor/bin/drush updb -y
- name: Export config after updates
shell: bash
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'
shell: bash
run: vendor/bin/grumphp git:deinit
- name: Create a pull request
uses: peter-evans/create-pull-request@v6
id: cpr
with:
token: ${{ inputs.repository_token }}
commit-message: |
Update modules
${{ steps.commit-body.outputs.commit_body }}
signoff: false
branch: hotfix/${{ steps.semvers.outputs.patch }}
base: ${{ inputs.branch }}
delete-branch: false
title: Update modules
body: |
${{ steps.commit-body.outputs.commit_body }}
labels: |
updates
automated pr
draft: true
committer: ${{ inputs.committer != '' && inputs.committer || format('{0} <{0}@users.noreply.github.com>', github.actor) }}
author: ${{ inputs.author != '' && inputs.author || format('{0} <{0}@users.noreply.github.com>', github.actor) }}
- 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>