-
-
Notifications
You must be signed in to change notification settings - Fork 9
720 lines (617 loc) · 28.8 KB
/
build-test-push.yml
File metadata and controls
720 lines (617 loc) · 28.8 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
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
name: Build, test and push to the Client Library
on:
workflow_dispatch:
inputs:
production:
description: |
'Push to production registries'
'not checked - to testing'
required: true
type: boolean
default: false
notify_mattermost:
description: 'Send notification to Mattermost'
required: true
type: boolean
default: false
version_major:
description: 'AlmaLinux major version'
required: true
default: '10'
type: choice
options:
- 10-kitten
- 10
- 9
- 8
type_default:
description: 'default'
required: true
type: boolean
default: true
type_minimal:
description: 'minimal'
required: true
type: boolean
default: true
type_micro:
description: 'micro'
required: true
type: boolean
default: true
type_base:
description: 'base'
required: true
type: boolean
default: true
type_init:
description: 'init'
required: true
type: boolean
default: true
type_toolbox:
description: 'toolbox'
required: true
type: boolean
default: true
schedule:
# run every day at 04:00 UTC
- cron: '00 04 * * *'
env:
# List of versions to build on schedule
# TODO: add 10 when it is released
# Kitten should not be built on schedule
versions_list: '"8", "9", "10"'
# List image types to build on schedule
image_types: '"default", "minimal", "micro", "base", "init", "toolbox"'
# Latest version
version_latest: 10
# Platforms list
platforms: 'linux/amd64, linux/ppc64le, linux/s390x, linux/arm64'
# Registries lists
registries_production: 'docker.io/almalinux, quay.io/almalinuxorg, ghcr.io/almalinux'
registries_testing: 'quay.io/almalinuxautobot'
jobs:
init-data:
name: Set matrix, prepare variables
runs-on: ubuntu-24.04
outputs:
version_major_matrix: ${{ steps.init-data.outputs.version_major_matrix }}
image_types_matrix: ${{ steps.init-data.outputs.image_types_matrix }}
production: ${{ steps.init-data.outputs.production }}
notify_mattermost: ${{ steps.init-data.outputs.notify_mattermost }}
date_time_stamp: ${{ steps.init-data.outputs.date_time_stamp }}
date_stamp: ${{ steps.init-data.outputs.date_stamp }}
time_stamp: ${{ steps.init-data.outputs.time_stamp }}
steps:
- name: Set matrix, prepare variables
id: init-data
run: |
# Set matrix, prepare variables
case ${{ github.event_name }} in
workflow_dispatch)
# Set image types matrix based on boolean inputs.type_* with true value
echo "image_types_matrix=$(jq -c <<< '[${{ format('"{0}", "{1}", "{2}", "{3}", "{4}", "{5}"', ( inputs.type_default && 'default' ), ( inputs.type_minimal && 'minimal' ), ( inputs.type_micro && 'micro' ), ( inputs.type_base && 'base' ), ( inputs.type_init && 'init' ), ( inputs.type_toolbox && 'toolbox' ) ) }}]')" >> $GITHUB_OUTPUT
echo "version_major_matrix=$(jq -c <<< '["${{ inputs.version_major }}"]')" >> $GITHUB_OUTPUT
echo "production=${{ inputs.production }}" >> $GITHUB_OUTPUT
echo "notify_mattermost=${{ inputs.notify_mattermost }}" >> $GITHUB_OUTPUT
;;
schedule)
# Set image types matrix based on the environment variable image_types: '"type1", "type2"'
echo "image_types_matrix=$(jq -c <<< '[${{ env.image_types }}]')" >> $GITHUB_OUTPUT
echo "version_major_matrix=$(jq -c <<< '[${{ env.versions_list }}]')" >> $GITHUB_OUTPUT
echo "production=false" >> $GITHUB_OUTPUT # only testing if scheduled
echo "notify_mattermost=true" >> $GITHUB_OUTPUT # always notify if scheduled
;;
esac
# date and time stamps
date_time_stamp=$(date -u '+%Y%m%d%H%M%S')
date_stamp=${date_time_stamp:0:-6}
time_stamp=${date_time_stamp:8}
time_stamp="${time_stamp:0:2}:${time_stamp:2:2}:${time_stamp:4:2}"
echo "date_time_stamp=${date_time_stamp}" >> "$GITHUB_OUTPUT"
echo "date_stamp=${date_stamp}" >> "$GITHUB_OUTPUT"
echo "time_stamp=${time_stamp}" >> "$GITHUB_OUTPUT"
build-test-push:
name: Deploy ${{ matrix.version_major }} ${{ matrix.image_types }} images
runs-on: ubuntu-24.04
needs: [init-data]
strategy:
fail-fast: false
matrix:
version_major: ${{ fromJSON(needs.init-data.outputs.version_major_matrix) }}
image_types: ${{ fromJSON(needs.init-data.outputs.image_types_matrix) }}
exclude:
- image_types: 'false'
env:
date_time_stamp: ${{ needs.init-data.outputs.date_time_stamp }}
date_stamp: ${{ needs.init-data.outputs.date_stamp }}
time_stamp: ${{ needs.init-data.outputs.time_stamp }}
notify_mattermost: ${{ needs.init-data.outputs.notify_mattermost }}
production: ${{ needs.init-data.outputs.production }}
steps:
-
name: Prepare AlmaLinux Minor version number
run: |
case ${{ matrix.version_major }} in
8)
version_minor=".10" ;;
9)
version_minor=".7" ;;
10)
version_minor=".1" ;;
10-kitten)
version_minor= ;;
*)
echo "Almalinux ${{ matrix.version_major }} is not supported!" && false
esac
echo "version_minor=${version_minor}" >> $GITHUB_ENV
-
name: Check update
id: check-update
run: |
# dnf check-update --secseverity=Important
# exit codes:
# 0 - no updates
# 100 - updates available
# 125 - tag not found
# 127 - command not found
# 255 - workflow_dispatch run
check_update=0
podman run --quiet --rm quay.io/almalinuxorg/almalinux:${{ matrix.version_major }} \
dnf check-update --secseverity=Important || \
check_update=$?
[[ "${{ github.event_name }}" == "workflow_dispatch" ]] && \
check_update=255
echo "check_update=${check_update}" >> "$GITHUB_ENV"
echo "Exit code: '$check_update'"
-
name: Set platforms and registries
if: env.check_update != 0
run: |
# Platforms
platforms="${{ env.platforms }}"
case ${{ matrix.version_major }} in
8|9)
platforms="linux/386, ${platforms}" ;;
10)
platforms="linux/amd64/v2, ${platforms}" ;;
10-kitten)
platforms="linux/386, linux/riscv64, linux/amd64/v2, ${platforms}" ;;
esac
echo "platforms=${platforms}" >> $GITHUB_ENV
# Registries
registries="${{ env.registries_testing }}"
[[ "${{ needs.init-data.outputs.production }}" == "true" ]] && \
registries="${{ env.registries_production }}"
echo "registries=${registries}" >> $GITHUB_ENV
-
name: Generate list of images to use as base name for tags
if: env.check_update != 0
run: |
# list of registries to push to
REGISTRIES="${{ env.registries }}"
IMAGE_NAMES=
# generate image names in format $REGISTRY/almalinux or $REGISTRY/${{ matrix.version_major }}-${{ matrix.image_types }}
# image names are used by docker/metadata-action to set 'images'
for REGISTRY in ${REGISTRIES//,/ }; do
# 'default' images should not go to docker.io
[ "${{ matrix.image_types }}" = "default" ] && [[ $REGISTRY = *'docker.io'* ]] && continue
# 'default' images goes to $REGISTRY/almalinux
[ "${{ matrix.image_types }}" = "default" ] \
&& IMAGE_NAME="$REGISTRY/almalinux" \
|| IMAGE_NAME="$REGISTRY/${{ matrix.version_major }}-${{ matrix.image_types }}"
IMAGE_NAMES="${IMAGE_NAMES} ${IMAGE_NAME}"
unset IMAGE_NAME
done
# remove space at the beginning of string
IMAGE_NAMES=${IMAGE_NAMES# }
# separate with comma instead of space and export to the action
echo "IMAGE_NAMES=${IMAGE_NAMES// /,}" >> $GITHUB_ENV
# [Debug]
echo $IMAGE_NAMES
-
name: Enable containerd image store, set Docker data-root
if: env.check_update != 0
run: |
# JQ file to switch into containerd image store and set Docker data-root
cat << EOF > containerd-snapshotter.jq
.features |= . + { "containerd-snapshotter": true } |
."data-root" ="/mnt/docker"
EOF
sudo sh -c 'jq -n -f containerd-snapshotter.jq > /etc/docker/daemon.json'
sudo systemctl restart docker
docker info -f '{{ .DriverStatus }}'
echo "[Debug] Docker data-root:"
docker info -f '{{ .DockerRootDir }}'
-
name: Checkout ${{ github.repository }}, branch 'main'
if: env.check_update != 0
uses: actions/checkout@v6
-
name: Checkout ${{ github.repository }}, branch '${{ matrix.version_major }}', path '${{ matrix.version_major }}'
if: env.check_update != 0
uses: actions/checkout@v6
with:
ref: ${{ matrix.version_major }}
path: ${{ matrix.version_major }}
-
name: Set up QEMU
if: env.check_update != 0
uses: docker/setup-qemu-action@v4
-
name: Set up Docker Buildx
if: env.check_update != 0
uses: docker/setup-buildx-action@v4
-
name: Login to Docker.io
if: contains(env.registries, 'docker.io') && env.check_update != 0
uses: docker/login-action@v4
with:
registry: docker.io
username: ${{ env.production == 'true' && secrets.DOCKERHUB_USERNAME || secrets.TEST_DOCKERHUB_USERNAME }}
password: ${{ env.production == 'true' && secrets.DOCKERHUB_TOKEN || secrets.TEST_DOCKERHUB_TOKEN }}
-
name: Login to Quay.io
if: contains(env.registries, 'quay.io') && env.check_update != 0
uses: docker/login-action@v4
with:
registry: quay.io
username: ${{ env.production == 'true' && secrets.QUAY_IO_USERNAME || secrets.TEST_QUAY_IO_USERNAME }}
password: ${{ env.production == 'true' && secrets.QUAY_IO_CLI_PASSWORD || secrets.TEST_QUAY_IO_CLI_PASSWORD }}
-
name: Login to Ghcr.io
if: contains(env.registries, 'ghcr.io') && env.check_update != 0
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ env.production == 'true' && secrets.GIT_HUB_USERNAME || secrets.TEST_GITHUB_USERNAME }}
password: ${{ env.production == 'true' && secrets.GIT_HUB_TOKEN || secrets.TEST_GITHUB_TOKEN }}
-
name: Generate tags and prepare metadata to build and push
if: env.check_update != 0
id: meta
uses: docker/metadata-action@v6
with:
# list of Docker images to use as base names for tags
images: ${{ env.IMAGE_NAMES }}
# list of tags
tags: |
type=raw,value=latest,enable=${{ matrix.image_types != 'default' || ( matrix.image_types == 'default' && matrix.version_major == env.version_latest ) }}
type=raw,value=${{ matrix.version_major }},enable=true
type=raw,value=${{ matrix.version_major }}${{ env.version_minor }},enable=true
type=raw,value=${{ matrix.version_major }}${{ env.version_minor }}-${{ env.date_stamp }},enable=true
-
name: Build images
if: env.check_update != 0
id: build-images
uses: docker/build-push-action@v7
with:
provenance: false
context: "{{defaultContext}}:Containerfiles/${{ matrix.version_major }}"
file: ./Containerfile.${{ matrix.image_types }}
platforms: ${{ env.platforms }}
push: false
load: true
tags: ${{ steps.meta.outputs.tags }}
-
name: Test images
if: env.check_update != 0
id: test-images
run: |
# [Test]
# Release string and file name
if [[ ${{ matrix.version_major }} != *'kitten'* ]]; then
release_string="AlmaLinux release ${{ matrix.version_major }}${{ env.version_minor }}"
else
# TODO: change to the actual number when Kitten new release is available
release_string="AlmaLinux Kitten release 10"
fi
echo "release_string=${release_string}" >> $GITHUB_ENV
# Container platform to architecture mapping
declare -A platform_to_arch
platform_to_arch["linux/riscv64"]="riscv64"
platform_to_arch["linux/amd64"]="x86_64"
platform_to_arch["linux/ppc64le"]="ppc64le"
platform_to_arch["linux/s390x"]="s390x"
platform_to_arch["linux/arm64"]="aarch64"
if [[ ${{ matrix.image_types }} == *'micro'* ]]; then
# Machine hardware name is x86_64 on linux/386 and linux/amd64/v2 platforms
platform_to_arch["linux/386"]="x86_64"
platform_to_arch["linux/amd64/v2"]="x86_64"
arch_query="uname -m"
else
platform_to_arch["linux/386"]="i686"
platform_to_arch["linux/amd64/v2"]="x86_64_v2"
arch_query="rpm -qf --queryformat '%{ARCH}' /etc/almalinux-release"
fi
platforms="${{ env.platforms }}"
for platform in ${platforms//,/ }; do
echo "Testing AlmaLinux ${{ matrix.version_major }} ${{ matrix.image_types }} image for ${platform}:"
docker run --platform=${platform} ${{ steps.build-images.outputs.digest }} /bin/bash -c " \
echo \"\$(cat /etc/almalinux-release) \$(${arch_query})\"" | \
grep -E "${release_string}.*${platform_to_arch[${platform}]}"
done
-
name: Push images to Client Library
if: env.check_update != 0
id: push-images
uses: docker/build-push-action@v7
with:
provenance: false
context: "{{defaultContext}}:Containerfiles/${{ matrix.version_major }}"
file: ./Containerfile.${{ matrix.image_types }}
platforms: ${{ env.platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
-
name: Generate Docker Hub README
if: contains(env.registries, 'docker.io') && matrix.image_types != 'default' && env.check_update != 0
env:
TAGS: ${{ steps.meta.outputs.tags }}
run: |
# Generate Docker Hub repository README from template
export image_type="${{ matrix.image_types }}"
export version="${{ matrix.version_major }}"
# Image type description
case ${image_type} in
base)
export type_desc="The Base Image is designed to be a base for your containerized applications, middleware and utilities. Includes helpful OS tools like find, tar, vi, etc., and a full DNF stack." ;;
minimal)
export type_desc="The Minimal Image is a stripped-down image that uses microdnf as package manager. Designed for applications that come with their own dependencies bundled (e.g. GO, NodeJS, Java)." ;;
micro)
export type_desc="The Micro Image is distributed without any package manager. Uses the package manager on the underlying host to install packages, typically using Buildah or Multi-stage builds with Podman. The most secure and smallest image." ;;
init)
export type_desc="The Init Image extends the base image, designed to run an init system as PID 1 for running multi-services inside a container. Systemd is enabled as init system." ;;
toolbox)
export type_desc="The Toolbox Image is designed to be used with toolbox or distrobox utilities for development and debugging." ;;
*)
export type_desc="AlmaLinux ${version} ${image_type} container image." ;;
esac
# Extract Docker Hub namespace from registries (e.g. 'docker.io/almalinux' -> 'almalinux')
export dockerhub_namespace=$(echo "${{ env.registries }}" | tr ',' '\n' | grep 'docker.io' | sed 's|.*docker.io/||;s|[[:space:]]||g')
echo "dockerhub_namespace=${dockerhub_namespace}" >> $GITHUB_ENV
# Extract tag names from docker.io tags, strip the repository prefix
export supported_tags=$(echo "${TAGS}" | grep 'docker.io' | sed 's|.*/[^:]*:|- `|;s|$|`|')
# Prepare platforms list in markdown format
platforms="${{ env.platforms }}"
export platforms_list="- \`${platforms//, /\`$'\n'- \`}\`"
envsubst < .github/dockerhub-readme.md.tmpl > dockerhub-readme.md
-
name: Update Docker Hub repository description
if: contains(env.registries, 'docker.io') && matrix.image_types != 'default' && env.check_update != 0
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ env.production == 'true' && secrets.DOCKERHUB_USERNAME || secrets.TEST_DOCKERHUB_USERNAME }}
password: ${{ env.production == 'true' && secrets.DOCKERHUB_TOKEN || secrets.TEST_DOCKERHUB_TOKEN }}
repository: ${{ env.dockerhub_namespace }}/${{ matrix.version_major }}-${{ matrix.image_types }}
short-description: ${{ env.release_string }} ${{ matrix.image_types }} container image
readme-filepath: ./dockerhub-readme.md
-
name: Prepare Mattermost message
if: env.check_update != 0
run: |
# Mattermost message heading
cat << 'EOF'> ${{ matrix.version_major }}_mattermost.md
**AlmaLinux OS ${{ matrix.version_major }}${{ env.version_minor }}** Container Image, build `${{ needs.init-data.outputs.date_time_stamp }}`, generated by the [GitHub Action](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
Platforms:
```
${{ env.platforms }}
```
EOF
# Mattermost message body
cat << 'EOF'> ${{ matrix.version_major }}_${{ matrix.image_types }}_mattermost.md
:almalinux: **${{ matrix.image_types }}**
```
${{ steps.meta.outputs.tags }}
```
EOF
- name: Upload Mattermost message artifacts
uses: actions/upload-artifact@v7
if: env.check_update != 0
with:
name: mattermost-message-${{ matrix.version_major }}-${{ matrix.image_types }}
path: ${{ matrix.version_major }}*_mattermost.md
-
name: Extract RootFS (default and minimal only)
id: extract-rootfs
# 'default' or 'minimal' images only go to Docker Official Library
if: ( matrix.image_types == 'default' || matrix.image_types == 'minimal' ) && env.check_update != 0
run: |
# [RootFS]
# File name for RootFS file (packed with tag + Xz)
name=almalinux-${{ matrix.version_major }}-${{ matrix.image_types }}
pwd=$( pwd )
path=${pwd}/${name}
almalinux_release='almalinux-release'
[ "${{ matrix.version_major }}" = "10-kitten" ] && almalinux_release='almalinux-kitten-release'
# The "tar file" for 'docker save' to write to
tar_name=${pwd}/${name}.tar
mkdir ${path}
cd ${path}
# Produce a tarred repository and save it to the "tar file".
docker save ${{ steps.build-images.outputs.digest }} -o ${tar_name}
# Extract the "tar file"
tar xf ${tar_name}
cd blobs/sha256
# The "temporary Dockerfile" to build image based on RootFS
cat <<EOF > Dockerfile
FROM scratch
ADD rootfs.tar.gz /
CMD ["/bin/bash"]
EOF
# Loop blobs to find all zipped files that are RootFS for a particular architecture
for file in `find . -type f`; do
if file --brief ${file} | grep -i gzip >/dev/null; then
# Make a copy of "taken RootFS"
cp -av ${file} rootfs.tar.gz
# Build an image from the "temporary Dockerfile"
docker build -t rootfs .
# Run the image and query almalinux-release package's architecture
arch=$( docker run --rm rootfs /bin/bash -c "rpm -q --qf=%{ARCH} ${almalinux_release}" )
# Map found architecture to the corresponding platform
platform=
docker rmi rootfs
case ${arch} in
i686)
platform=386;;
x86_64)
platform=amd64;;
x86_64_v2)
platform=amd64_v2;;
ppc64le)
platform=ppc64le;;
s390x)
platform=s390x;;
aarch64)
platform=arm64;;
riscv64)
platform=riscv64;;
*)
echo "The '$arch' is incorrect or failed to determine architecture." && false;;
esac
# Delete copy of the "taken RootFS"
rm -f rootfs.tar.gz
# Copy the "taken RootFS" into corresponded .tar.xz
cp -av ${file} ${name}-${platform}.tar.gz
zcat ${name}-${platform}.tar.gz | xz -9 -e -T0 > ${pwd}/${{ matrix.version_major }}/${{ matrix.image_types }}/${platform}/${name}-${platform}.tar.xz
fi
done
# Clean up
rm -rf ${path}
echo "[Debug]"
ls -1 ${pwd}/${{ matrix.version_major }}/${{ matrix.image_types }}/*/*.tar.xz
# Change date stamp in '${version_major}/${image_types}/${arch}/Dockerfile'
-
name: Change date stamp in Dockerfile (default and minimal only)
# 'default' or 'minimal' images only go to Docker Official Library
if: ( matrix.image_types == 'default' || matrix.image_types == 'minimal' ) && env.check_update != 0
run: |
# [Dockerfile]
platforms="${{ env.platforms }}"
for platform in ${platforms//,/ }; do
arch=${platform#linux/}
arch=${arch/\//_}
dockerfile=${{ matrix.version_major }}/${{ matrix.image_types }}/${arch}/Dockerfile
case ${{ matrix.image_types }} in
default)
tags="${{ matrix.version_major }}${{ env.version_minor }}, ${{ matrix.version_major }}${{ env.version_minor }}-${{ env.date_stamp }}"
[ "${{ matrix.version_major }}" != "10-kitten" ] && tags="${{ matrix.version_major }}, ${tags}"
[ "${{ matrix.version_major }}" = "${{ env.version_latest }}" ] && tags="latest, ${tags}" ;;
minimal)
tags="${{ matrix.version_major }}${{ env.version_minor }}-${{ matrix.image_types }}, ${{ matrix.version_major }}${{ env.version_minor }}-${{ matrix.image_types }}-${{ env.date_stamp }}"
[ "${{ matrix.version_major }}" != "10-kitten" ] && tags="${{ matrix.version_major }}-${{ matrix.image_types }}, ${tags}"
[ "${{ matrix.version_major }}" = "${{ env.version_latest }}" ] && tags="minimal, ${tags}" ;;
*)
esac
# Tags: 8, 8.9, 8.9-20231124
sed -i "/^\([[:space:]]*#[[:space:]]*Tags: \).*/s//\1${tags}/" ${dockerfile}
echo "[Debug] ${dockerfile}"
cat ${dockerfile}
done
# Commit '${version_major}/${image_types}/${arch}/*'
-
name: "Commit and push ${{ matrix.image_types }}/*/* Dockerfile and RootFS (branch ${{ matrix.version_major }})"
# 'default' or 'minimal' images only and 'Push to production' is checked
if: ( matrix.image_types == 'default' || matrix.image_types == 'minimal' ) && env.production == 'true' && env.check_update != 0
uses: EndBug/add-and-commit@v9
with:
default_author: user_info
new_branch: ${{ matrix.version_major }}
cwd: ${{ matrix.version_major }}
pull: '--rebase --autostash'
message: "AlmaLinux ${{ matrix.version_major }} ${{ matrix.image_types }} - ${{ env.date_stamp }} ${{ env.time_stamp }} (generated on ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
push: true
notify-mattermost:
name: Mattermost notification
runs-on: ubuntu-24.04
needs: [init-data, build-test-push]
if: needs.init-data.outputs.notify_mattermost == 'true'
strategy:
fail-fast: false
matrix:
version_major: ${{ fromJSON(needs.init-data.outputs.version_major_matrix) }}
steps:
- name: Download Mattermost message artifacts
uses: actions/download-artifact@v8
- name: Create Mattermost message
run: |
# Artifacts are downloaded into mattermost-message-${{ matrix.version_major }}-* directory
# Find any ${{ matrix.version_major }}_mattermost.md over all image types and copy it to the current directory
# If no such file found, set notify_mattermost to false and exit (no notification will be sent)
# If found, set MATTERMOST_TEXT environment variable with complete message
notify_mattermost=true
mattermost_md=$(ls -1 mattermost-message-${{ matrix.version_major }}-*/${{ matrix.version_major }}_mattermost.md 2>/dev/null | head -1)
if [ -f "${mattermost_md}" ]; then
cp -av "${mattermost_md}" .
else
notify_mattermost=false
fi
echo "notify_mattermost=${notify_mattermost}" >> $GITHUB_ENV
[ "${notify_mattermost}" = "false" ] && exit 0
# MATTERMOST_TEXT environment variable with complete message
{
echo 'MATTERMOST_TEXT<<EOF'
cat ${{ matrix.version_major }}_mattermost.md
cat mattermost-message-${{ matrix.version_major }}-*/${{ matrix.version_major }}_*_mattermost.md
echo EOF
} >> "$GITHUB_ENV"
- name: Send notification to Mattermost
if: env.notify_mattermost == 'true'
uses: mattermost/action-mattermost-notify@master
with:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
MATTERMOST_CHANNEL: ${{ vars.MATTERMOST_CHANNEL }}
MATTERMOST_USERNAME: ${{ github.triggering_actor }}
TEXT: ${{ env.MATTERMOST_TEXT }}
optimize-repo-size:
# 'default' or 'minimal' images only and 'Push to production' is checked or scheduled run
if: ( contains(needs.init-data.outputs.image_types_matrix, 'default') || contains(needs.init-data.outputs.image_types_matrix, 'minimal') ) && needs.init-data.outputs.production == 'true'
name: Optimize size of repository, branch '${{ matrix.version_major }}'
runs-on: ubuntu-24.04
needs:
- init-data
- build-test-push
strategy:
fail-fast: false
matrix:
version_major: ${{ fromJSON(needs.init-data.outputs.version_major_matrix) }}
steps:
-
name: Checkout ${{ github.repository }}, branch '${{ matrix.version_major }}', path '${{ matrix.version_major }}'
uses: actions/checkout@v6
with:
ref: ${{ matrix.version_major }}
path: ${{ matrix.version_major }}
-
name: Optimize size of branch the '${{ matrix.version_major }}'
run: |
date_stamp=${{ needs.init-data.outputs.date_stamp }}
cd ${{ matrix.version_major }}
echo "Prepare new branch 'tmp' based on ${{ matrix.version_major }}"
git checkout -b tmp
echo "Delete local branch '${{ matrix.version_major }}'"
git branch -D ${{ matrix.version_major }}
echo "Preserve resent data"
mkdir ../tmp-${date_stamp}
mv ./default ../tmp-${date_stamp}/
mv ./minimal ../tmp-${date_stamp}/
echo "Crete orphan branch '${{ matrix.version_major }}'"
git checkout --orphan ${{ matrix.version_major }}
echo "Clean up"
git rm --cached -r .
rm -rf ./default
rm -rf ./minimal
echo "Restore resent data"
mv ../tmp-${date_stamp}/default ./
mv ../tmp-${date_stamp}/minimal ./
echo "[Debug]"
git status
-
name: Commit and push ${{ github.repository }}, branch '${{ matrix.version_major }}'
uses: EndBug/add-and-commit@v9
with:
default_author: user_info
message: "Update AlmaLinux ${{ matrix.version_major }} - ${{ needs.init-data.outputs.date_stamp }} ${{ needs.init-data.outputs.time_stamp }} (generated on ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
push: '--force --set-upstream origin ${{ matrix.version_major }}'
cwd: ${{ matrix.version_major }}