-
Notifications
You must be signed in to change notification settings - Fork 4
107 lines (95 loc) · 3.74 KB
/
update-config.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
on:
workflow_dispatch:
repository_dispatch:
types: [config_change]
name: Update config
env:
GH_TOKEN: ${{ github.token }}
jobs:
update-config:
runs-on: ubuntu-latest
container:
image: ghcr.io/city-of-helsinki/drupal-php-docker:8.3-alpine
services:
db:
image: mysql:8
env:
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_DATABASE: drupal
MYSQL_ROOT_PASSWORD: drupal
ports:
- 3306:3306
steps:
- uses: actions/checkout@v4
- name: Check if required secrets are set
env:
AUTOMATIC_UPDATE_TOKEN: ${{ secrets.AUTOMATIC_UPDATE_TOKEN }}
if: env.AUTOMATIC_UPDATE_TOKEN == ''
run: exit 1
- name: Download latest dump
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh run download -n latest.sql
- name: Prepare setup
run: |
# We install Drupal from existing dump, so locale_install() hook
# is never fired. Make sure the translations folder exists.
mkdir -p public/sites/default/files/translations -p
- name: Build project
run: |
composer install --no-interaction
$(drush sql:connect) < latest.sql
drush cim -y && drush updb -y && drush cr
composer update drupal/helfi_* drupal/hdbt* -W --no-interaction
drush cr
# Update translations from localize.drupal.org and helfi-modules
# before running update hooks to reduce clutter in configuration files.
drush locale:check && drush locale:update
drush updb -y
# Update translations from helfi_platform_config. These translations
# consists of overrides for non customised translations and will
# override current translation with a non customised translation.
drush helfi:locale-import helfi_platform_config
drush cex -y
# Update platform
drush helfi:tools:update-platform
- name: Check module versions
id: module-status
run: |
MODE="delete"
drush helfi:tools:check-composer-versions $GITHUB_WORKSPACE/composer.lock --format=markdown_table >> $GITHUB_STEP_SUMMARY && EXIT_CODE=$? || EXIT_CODE=$?
if [ "$EXIT_CODE" -eq 3 ]; then
MODE="upsert"
echo " " >> $GITHUB_STEP_SUMMARY
echo ":warning: Failed to install the latest version of the packages listed above" >> $GITHUB_STEP_SUMMARY
echo " " >> $GITHUB_STEP_SUMMARY
echo "Please run \`composer why-not drupal/package_name package_version\` to see why." >> $GITHUB_STEP_SUMMARY
fi
echo "MODE=$MODE" >> $GITHUB_OUTPUT
cat $GITHUB_STEP_SUMMARY > /tmp/pr-message.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: Update configuration
token: ${{ secrets.AUTOMATIC_UPDATE_TOKEN }}
title: Automatic update
labels: auto-update
body: |
- Updated active configuration.
- Updated platform
branch: update-configuration
- name: Attempt to find PR
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
id: find-pr
run: echo "number=$(gh pr list --base ${BRANCH_NAME} --head update-configuration --json number --jq '.[].number')" >> $GITHUB_OUTPUT
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
if: ${{ steps.find-pr.outputs.number != '' }}
with:
comment_tag: status
mode: ${{ steps.module-status.outputs.MODE }}
filePath: /tmp/pr-message.txt
pr_number: ${{ steps.find-pr.outputs.number }}