-
Notifications
You must be signed in to change notification settings - Fork 1
350 lines (318 loc) · 17.3 KB
/
element-with-modules.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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
name: Element with modules
on:
push:
branches: # we want to build the widgets from the push into Element staging and publish a main container
- main
tags: # we want to build the stable widgets into stable Element and publish the container
- '@nordeck/element*module*'
pull_request: # we want to build the widgets from the PR into Element develop & staging
schedule: # we want to build the stable widgets into stable Element and publish the container, plus a verification of all dev versions on a daily basis
- cron: '0 5 * * 1-5'
workflow_dispatch: # we build whatever the user inputs and publish the container
inputs:
element:
description: 'Element Web version (git ref, default=develop)'
type: 'string'
guestModule:
description: 'Element Guest module version (release tag/git ref/none, default=main)'
type: 'string'
opendeskModule:
description: 'Element openDesk module version (release tag/git ref/none, default=main)'
type: 'string'
lifecycleModule:
description: 'Element Widget Lifecycle module version (release tag/git ref/none, default=main)'
type: 'string'
togglesModule:
description: 'Element Widget Toggles module version (release tag/git ref/none, default=main)'
type: 'string'
jobs:
determine-versions:
name: Determine the versions for which to build containers to feed into the next job
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
outputs:
matrix: ${{ env.MATRIX }}
steps:
- name: Determine Element Web versions
run: |
VERSION_ELEMENT_DEV="develop" # Element develop branch
VERSION_ELEMENT_STAGING="staging" # Element branch with the latest release candidate
VERSION_ELEMENT_STABLE="master" # Element cut their releases from master branch
VERSION_ELEMENT="$VERSION_ELEMENT_DEV"
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/heads/main') }}; then VERSION_ELEMENT="$VERSION_ELEMENT_STAGING"; fi
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/tags/') }}; then VERSION_ELEMENT="$VERSION_ELEMENT_STABLE"; fi
if [[ "${{ inputs.element }}" != "" ]]; then VERSION_ELEMENT="${{ inputs.element }}"; fi
echo "VERSION_ELEMENT=$VERSION_ELEMENT" >> $GITHUB_ENV
echo "VERSION_ELEMENT_STAGING=$VERSION_ELEMENT_STAGING" >> $GITHUB_ENV
echo "VERSION_ELEMENT_STABLE=$VERSION_ELEMENT_STABLE" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Determine Guest module versions
run: |
VERSION_MOD_GUEST_STABLE="$(git describe --match="@nordeck/element-web-guest-module*" --abbrev=0)"
VERSION_MOD_GUEST="main" # Development version
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/tags/') }}; then VERSION_MOD_GUEST="$VERSION_MOD_GUEST_STABLE"; fi # latest release
if [[ "${{ github.event_name }}" == "pull_request" ]]; then VERSION_MOD_GUEST=${{ github.sha }}; fi # the local PR version
if [[ "${{ inputs.guestModule }}" != "" ]]; then VERSION_MOD_GUEST=${{ inputs.guestModule }}; fi
echo "VERSION_MOD_GUEST=$VERSION_MOD_GUEST" >> $GITHUB_ENV
echo "VERSION_MOD_GUEST_STABLE=$VERSION_MOD_GUEST_STABLE" >> $GITHUB_ENV
- name: Determine openDesk module versions
run: |
VERSION_MOD_OPENDESK_STABLE="$(git describe --match="@nordeck/element-web-opendesk-module*" --abbrev=0)"
VERSION_MOD_OPENDESK="main" # Development version
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/tags/') }}; then VERSION_MOD_OPENDESK="$VERSION_MOD_OPENDESK_STABLE"; fi # latest release
if [[ "${{ github.event_name }}" == "pull_request" ]]; then VERSION_MOD_OPENDESK=${{ github.sha }}; fi # the local PR version
if [[ "${{ inputs.opendeskModule }}" != "" ]]; then VERSION_MOD_OPENDESK=${{ inputs.opendeskModule }}; fi
echo "VERSION_MOD_OPENDESK=$VERSION_MOD_OPENDESK" >> $GITHUB_ENV
echo "VERSION_MOD_OPENDESK_STABLE=$VERSION_MOD_OPENDESK_STABLE" >> $GITHUB_ENV
- name: Determine Widget Lifecycle module versions
run: |
VERSION_MOD_LIFECYCLE_STABLE="$(git describe --match="@nordeck/element-web-widget-lifecycle-module*" --abbrev=0)" # latest release
VERSION_MOD_LIFECYCLE="main" # Development version
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/tags/') }}; then VERSION_MOD_LIFECYCLE="$VERSION_MOD_LIFECYCLE_STABLE"; fi # latest release
if [[ "${{ github.event_name }}" == "pull_request" ]]; then VERSION_MOD_LIFECYCLE=${{ github.sha }}; fi # the local PR version
if [[ "${{ inputs.lifecycleModule }}" != "" ]]; then VERSION_MOD_LIFECYCLE=${{ inputs.lifecycleModule }}; fi
echo "VERSION_MOD_LIFECYCLE=$VERSION_MOD_LIFECYCLE" >> $GITHUB_ENV
echo "VERSION_MOD_LIFECYCLE_STABLE=$VERSION_MOD_LIFECYCLE_STABLE" >> $GITHUB_ENV
- name: Determine Widget Toggles module versions
run: |
VERSION_MOD_TOGGLES_STABLE="$(git describe --match="@nordeck/element-web-widget-toggles-module*" --abbrev=0)"
VERSION_MOD_TOGGLES="main" # Development version
if [[ "${{ github.event_name }}" == "push" ]] && ${{ startsWith(github.ref, 'refs/tags/') }}; then VERSION_MOD_TOGGLES="$VERSION_MOD_TOGGLES_STABLE"; fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then VERSION_MOD_TOGGLES=${{ github.sha }}; fi # the local PR version
if [[ "${{ inputs.togglesModule }}" != "" ]]; then VERSION_MOD_TOGGLES=${{ inputs.togglesModule }}; fi
echo "VERSION_MOD_TOGGLES=$VERSION_MOD_TOGGLES" >> $GITHUB_ENV
echo "VERSION_MOD_TOGGLES_STABLE=$VERSION_MOD_TOGGLES_STABLE" >> $GITHUB_ENV
- name: Create job matrix from version combinations to build
# Create a JSON array of maps, each map being a combination of element + module versions.
# The next step will consume this as an input to a "matrix" configuration.
# We use only the "include" list for the matrix to define (a number of) sets of specific versions.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow#expanding-or-adding-matrix-configurations
run: |
LOCAL="{\"element\": \"${{ env.VERSION_ELEMENT }}\", \"guest\": \"${{ env.VERSION_MOD_GUEST }}\", \"opendesk\": \"${{ env.VERSION_MOD_OPENDESK }}\", \"lifecycle\": \"${{ env.VERSION_MOD_LIFECYCLE }}\", \"toggles\": \"${{ env.VERSION_MOD_TOGGLES }}\"}"
echo $LOCAL | jq
SECONDARY=""
if [[ "${{ github.event_name }}" == "pull_request" ]]
then
SECONDARY="{\"element\": \"${{ env.VERSION_ELEMENT_STAGING }}\", \"guest\": \"${{ env.VERSION_MOD_GUEST }}\", \"opendesk\": \"${{ env.VERSION_MOD_OPENDESK }}\", \"lifecycle\": \"${{ env.VERSION_MOD_LIFECYCLE }}\", \"toggles\": \"${{ env.VERSION_MOD_TOGGLES }}\"}"
echo $SECONDARY | jq
SECONDARY=",$SECONDARY"
elif [[ "${{ github.event_name }}" == "schedule" ]]
then
SECONDARY="{\"element\": \"${{ env.VERSION_ELEMENT_STABLE }}\", \"guest\": \"${{ env.VERSION_MOD_GUEST_STABLE }}\", \"opendesk\": \"${{ env.VERSION_MOD_OPENDESK_STABLE }}\", \"lifecycle\": \"${{ env.VERSION_MOD_LIFECYCLE_STABLE }}\", \"toggles\": \"${{ env.VERSION_MOD_TOGGLES_STABLE }}\"}"
echo $SECONDARY | jq
SECONDARY=",$SECONDARY"
fi
MATRIX="[${LOCAL}${SECONDARY}]"
echo $MATRIX | jq
echo "MATRIX=$MATRIX" >> $GITHUB_ENV
build-container:
name: Build OCI container of Element with modules
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
packages: write
needs: determine-versions
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.determine-versions.outputs.matrix) }}
env:
DOCKER_PLATFORMS: linux/amd64,linux/arm64
steps:
- name: Announce versions
run: |
echo "Building Element Web with modules, versions:"
echo "- Dockerfile ${{ github.sha }}"
echo "- Element Web ${{ matrix.element }}"
echo "- Guest module ${{ matrix.guest }}"
echo "- openDesk module ${{ matrix.opendesk }}"
echo "- Widget Lifecycle module ${{ matrix.lifecycle }}"
echo "- Widget Toggles module ${{ matrix.toggles }}"
- uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Set up build_config.yaml
run: |
echo "modules:" > ../build_config.yaml
- name: Checkout Guest module version
if: ${{ matrix.guest != 'none' }}
uses: actions/checkout@v4
with:
ref: '${{ matrix.guest }}'
fetch-tags: true
fetch-depth: 0
- name: Build Guest module
if: ${{ ! (startsWith(matrix.guest, '@nordeck') || startsWith(matrix.guest, 'none')) }}
run: |
yarn install --frozen-lockfile
yarn workspace @nordeck/element-web-guest-module package
mv packages/element-web-guest-module/nordeck-element-web-guest-module.tgz ../
- name: Generate Guest module build_config.yaml entry and customisations.json
if: ${{ matrix.guest != 'none' }}
env:
VERSION: ${{ matrix.guest }}
IS_REF: ${{ ! startsWith(matrix.guest, '@nordeck') }}
run: |
VERSION="${{ env.VERSION }}"
HUMAN_GUEST="v$(echo ${{ env.VERSION }} | tr "@" "\n" | tail -1)"
if ${{ env.IS_REF }}
then
VERSION="file:nordeck-element-web-guest-module.tgz"
HUMAN_GUEST="$(git describe --exclude='*' --always)"
fi
echo " - '$VERSION'" >> ../build_config.yaml
cp e2e/src/deploy/elementWeb/customisations.json ../
HUMAN_GUEST="+g-${HUMAN_GUEST}"
echo "HUMAN_GUEST=$HUMAN_GUEST" >> $GITHUB_ENV
- name: Checkout openDesk module version
if: ${{ matrix.opendesk != 'none' }}
uses: actions/checkout@v4
with:
ref: '${{ matrix.opendesk }}'
fetch-tags: true
fetch-depth: 0
- name: Build openDesk module
if: ${{ ! (startsWith(matrix.opendesk, '@nordeck') || startsWith(matrix.opendesk, 'none')) }}
run: |
yarn install --frozen-lockfile
yarn workspace @nordeck/element-web-opendesk-module package
mv packages/element-web-opendesk-module/nordeck-element-web-opendesk-module.tgz ../
- name: Generate openDesk module build_config.yaml entry
if: ${{ matrix.opendesk != 'none' }}
env:
VERSION: ${{ matrix.opendesk }}
IS_REF: ${{ ! startsWith(matrix.opendesk, '@nordeck') }}
run: |
VERSION="${{ env.VERSION }}"
HUMAN_OPENDESK="v$(echo ${{ env.VERSION }} | tr "@" "\n" | tail -1)"
if ${{ env.IS_REF }}
then
VERSION="file:nordeck-element-web-opendesk-module.tgz"
HUMAN_OPENDESK="$(git describe --exclude='*' --always)"
fi
echo " - '$VERSION'" >> ../build_config.yaml
HUMAN_OPENDESK="+od-${HUMAN_OPENDESK}"
echo "HUMAN_OPENDESK=$HUMAN_OPENDESK" >> $GITHUB_ENV
- name: Checkout Widget Lifecycle module version
if: ${{ matrix.lifecycle != 'none' }}
uses: actions/checkout@v4
with:
ref: '${{ matrix.lifecycle }}'
fetch-tags: true
fetch-depth: 0
- name: Build Widget Lifecycle module
if: ${{ ! (startsWith(matrix.lifecycle, '@nordeck') || startsWith(matrix.lifecycle, 'none')) }}
run: |
yarn install --frozen-lockfile
yarn workspace @nordeck/element-web-widget-lifecycle-module package
mv packages/element-web-widget-lifecycle-module/nordeck-element-web-widget-lifecycle-module.tgz ../
- name: Generate Widget Lifecycle module build_config.yaml entry
if: ${{ matrix.lifecycle != 'none' }}
env:
VERSION: ${{ matrix.lifecycle }}
IS_REF: ${{ ! startsWith(matrix.lifecycle, '@nordeck') }}
run: |
VERSION="${{ env.VERSION }}"
HUMAN_LIFECYCLE="v$(echo ${{ env.VERSION }} | tr "@" "\n" | tail -1)"
if ${{ env.IS_REF }}
then
VERSION="file:nordeck-element-web-widget-lifecycle-module.tgz"
HUMAN_LIFECYCLE="$(git describe --exclude='*' --always)"
fi
echo " - '$VERSION'" >> ../build_config.yaml
HUMAN_LIFECYCLE="+wl-${HUMAN_LIFECYCLE}"
echo "HUMAN_LIFECYCLE=$HUMAN_LIFECYCLE" >> $GITHUB_ENV
- name: Checkout Widget Toggles module version
if: ${{ matrix.toggles != 'none' }}
uses: actions/checkout@v4
with:
ref: '${{ matrix.toggles }}'
fetch-tags: true
fetch-depth: 0
- name: Build Widget Toggles module
if: ${{ ! (startsWith(matrix.toggles, '@nordeck') || startsWith(matrix.toggles, 'none')) }}
run: |
yarn install --frozen-lockfile
yarn workspace @nordeck/element-web-widget-toggles-module package
mv packages/element-web-widget-toggles-module/nordeck-element-web-widget-toggles-module.tgz ../
- name: Generate Widget Toggles module build_config.yaml entry
if: ${{ matrix.toggles != 'none' }}
env:
VERSION: ${{ matrix.toggles }}
IS_REF: ${{ ! startsWith(matrix.toggles, '@nordeck') }}
run: |
VERSION=${{ env.VERSION }}
HUMAN_TOGGLES="v$(echo ${{ env.VERSION }} | tr "@" "\n" | tail -1)"
if ${{ env.IS_REF }}
then
VERSION="file:nordeck-element-web-widget-toggles-module.tgz"
HUMAN_TOGGLES="$(git describe --exclude='*' --always)"
fi
echo " - '$VERSION'" >> ../build_config.yaml
HUMAN_TOGGLES="+wt-${HUMAN_TOGGLES}"
echo "HUMAN_TOGGLES=$HUMAN_TOGGLES" >> $GITHUB_ENV
- name: Checkout Dockerfile version
uses: actions/checkout@v4
- name: Checkout Element version
uses: actions/checkout@v4
with:
repository: element-hq/element-web
ref: ${{ matrix.element }}
path: element-web
fetch-tags: true
- name: Determine human readable Element Web version
env:
IS_RELEASE: ${{ matrix.element == 'staging' || matrix.element == 'master' || startsWith(matrix.element,'v') }}
working-directory: element-web
run: |
HUMAN_ELEMENT="$(git describe --exclude='*' --always)"
if ${{ env.IS_RELEASE }}; then HUMAN_ELEMENT="$(git describe --abbrev=0)"; fi
echo "HUMAN_ELEMENT=$HUMAN_ELEMENT" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/nordeck/element-web-modules
labels: |
org.opencontainers.image.title=Element Web with modules
org.opencontainers.image.description=A ready to use Element Web with all Nordeck modules.
org.opencontainers.image.vendor=Nordeck IT + Consulting GmbH
tags: |
type=raw,value=ew-${{ env.HUMAN_ELEMENT }}${{ env.HUMAN_GUEST }}${{ env.HUMAN_OPENDESK }}${{ env.HUMAN_LIFECYCLE }}${{ env.HUMAN_TOGGLES }}
# It can't start with a period or hyphen and must be no longer than 128 characters.
- name: Collect module source files
run: |
mv ../build_config.yaml e2e/src/deploy/elementWeb/
mv ../customisations.json e2e/src/deploy/elementWeb/ || ${{ matrix.guest == 'none' }}
mv ../nordeck-element-web-guest-module.tgz e2e/src/deploy/elementWeb/ || ${{ startsWith(matrix.guest, '@nordeck') || startsWith(matrix.guest, 'none') }}
mv ../nordeck-element-web-opendesk-module.tgz e2e/src/deploy/elementWeb/ || ${{ startsWith(matrix.opendesk, '@nordeck') || startsWith(matrix.opendesk, 'none') }}
mv ../nordeck-element-web-widget-lifecycle-module.tgz e2e/src/deploy/elementWeb/ || ${{ startsWith(matrix.lifecycle, '@nordeck') || startsWith(matrix.lifecycle, 'none') }}
mv ../nordeck-element-web-widget-toggles-module.tgz e2e/src/deploy/elementWeb/ || ${{ startsWith(matrix.toggles, '@nordeck') || startsWith(matrix.toggles, 'none') }}
- name: Build
uses: docker/build-push-action@v6
with:
context: e2e/src/deploy/elementWeb/
build-args: |
ELEMENT_VERSION=${{ matrix.element }}
platforms: ${{ env.DOCKER_PLATFORMS }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) || github.event_name == 'schedule' && matrix.element == 'master' || github.event_name == 'workflow_dispatch' }}