forked from AlmaLinux/sig-livemedia
-
Notifications
You must be signed in to change notification settings - Fork 0
363 lines (305 loc) · 15 KB
/
build-media.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
351
352
353
354
355
356
357
358
359
360
361
362
363
name: Build Live images
on:
workflow_dispatch:
inputs:
GNOME:
description: 'GNOME'
required: true
type: boolean
default: false
GNOME-Mini:
description: 'GNOME-Mini'
required: true
type: boolean
default: true
KDE:
description: 'KDE'
required: true
type: boolean
default: false
MATE:
description: 'MATE'
required: true
type: boolean
default: false
XFCE:
description: 'XFCE'
required: true
type: boolean
default: false
version_major:
description: 'AlmaLinux major version'
required: true
default: '9'
type: choice
options:
- 9
- 8
store_as_artifact:
description: "Store media as action aftifact"
required: true
type: boolean
default: false
upload_to_s3:
description: "Upload to S3"
required: true
type: boolean
default: false
notify_mattermost:
description: "Send notification to Mattermost"
required: true
type: boolean
default: false
jobs:
build-media:
name: AlmaLinux ${{ inputs.version_major }} ${{ matrix.image_types }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Set image types matrix based on boolean inputs.* with true value
image_types: ${{ fromJSON(format('["{0}", "{1}", "{2}", "{3}", "{4}"]', ( inputs.GNOME && 'GNOME' ), ( inputs.GNOME-Mini && 'GNOME-Mini' ), ( inputs.KDE && 'KDE' ), ( inputs.MATE && 'MATE' ), ( inputs.XFCE && 'XFCE' ) )) }}
exclude:
- image_types: 'false'
steps:
- uses: actions/checkout@v4
name: Checkout ${{ github.action_repository }}
- name: Prepare AlmaLinux Minor version number
run: |
case ${{ inputs.version_major }} in
8)
version_minor="10" ;;
9)
version_minor="4" ;;
10)
version_minor="0" ;;
*)
echo "Almalinux ${{ inputs.version_major }} is not supported!" && false
esac
echo "version_minor=${version_minor}" >> $GITHUB_ENV
# [Debug]
echo "version_minor=${version_minor}"
- name: Prepare other stuff
run: |
# Name of repository to enable (PowerTools/CRB)
dnf_crb_repo="PowerTools"
if [ "${{ inputs.version_major }}" = "9" ]; then
dnf_crb_repo="CRB"
fi
echo "dnf_crb_repo=${dnf_crb_repo}" >> $GITHUB_ENV
# List of the packages to prepare build env
need_pkgs="lorax anaconda zstd"
if [ "${{ inputs.version_major }}" = "9" ]; then
need_pkgs="${need_pkgs} libblockdev-nvme"
fi
echo "need_pkgs=${need_pkgs}" >> $GITHUB_ENV
# Verify that CPU supports hardware virtualization
echo -n "Number of vmx|svm CPUs: " && grep -E -c '(vmx|svm)' /proc/cpuinfo
# Set ENV variable of for vagrant's config.vm.box
cp -av ci/vagrant/Vagrantfile ./
echo vm_box='almalinux/${{ inputs.version_major }}' > .env
# Kickstart file name
image_type=${{ matrix.image_types }}
image_type="${image_type,,}"
kickstart="almalinux-${{ inputs.version_major }}-live-${image_type}.ks"
echo "kickstart=${kickstart}" >> $GITHUB_ENV
# Livemedia creator results directory
livemedia_resultdir="/sig-livemedia"
echo "livemedia_resultdir=${livemedia_resultdir}" >> $GITHUB_ENV
# Volume ID
volid="AlmaLinux-${{ inputs.version_major }}_${{ env.version_minor }}-x86_64-Live-${{ matrix.image_types }}"
echo ${{ matrix.image_types }} | grep -i mini >/dev/null && volid="AlmaLinux-${{ inputs.version_major }}_${{ env.version_minor }}-x86_64-Live-Mini"
echo "volid=${volid}" >> $GITHUB_ENV
# Results file name
results_name="AlmaLinux-${{ inputs.version_major }}.${{ env.version_minor }}-x86_64-Live-${{ matrix.image_types }}"
echo "results_name=${results_name}" >> $GITHUB_ENV
# date stamp
date_stamp=$(date -u '+%Y%m%d%H%M%S')
echo "date_stamp=${date_stamp}" >> $GITHUB_ENV
# Results path on host
results_path="${{ github.workspace }}/results"
mkdir -p ${results_path}
echo "results_path=${results_path}" >> $GITHUB_ENV
- name: Create media creator script
run: |
cat <<'EOF'>./livemedia-creator.sh
livemedia-creator \
--ks=/vagrant/kickstarts/${{ env.kickstart }} \
--no-virt \
--resultdir ${{ env.livemedia_resultdir }}/iso_${{ matrix.image_types}} \
--project "AlmaLinux Live" \
--make-iso \
--iso-only \
--iso-name "${{ env.results_name }}.iso" \
--releasever 9.${{ env.version_minor }} \
--volid "${{ env.volid }}" \
--nomacboot \
--logfile ${{ env.livemedia_resultdir }}/logs/livemedia.log \
--anaconda-arg="--product AlmaLinux"
EOF
- name: Install KVM Packages and Start libvirt
run: |
sudo apt-get -y update
sudo apt-get -y install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
sudo systemctl enable --now libvirtd
sudo adduser "$(id -un)" libvirt
sudo adduser "$(id -un)" kvm
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Tune libvirt
run: virsh list --all
- name: Install the Vagrant and need plugins
run: |
sudo apt-get -y install vagrant
sudo vagrant plugin install vagrant-reload
sudo vagrant plugin install vagrant-env
- name: Install Libvirt Plugins
run: |
sudo cp /etc/apt/sources.list /etc/apt/sources.list."$(date +"%F")"
sudo sed -i -e '/^# deb-src.*universe$/s/# //g' /etc/apt/sources.list
sudo apt-get -y update
sudo apt-get -y install nfs-kernel-server
sudo systemctl enable --now nfs-server
sudo apt-get -y build-dep vagrant ruby-libvirt
sudo apt-get -y install ebtables dnsmasq-base
sudo apt-get -y install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
sudo vagrant plugin install vagrant-libvirt
sudo vagrant plugin install vagrant-scp
- name: Create 'mnt' Storage Pull
run: |
# sudo virsh pool-list
# sudo virsh pool-destroy default
# sudo virsh pool-undefine default
sudo virsh pool-define-as --name mnt --type dir --target /mnt
sudo virsh pool-autostart mnt
sudo virsh pool-start mnt
sudo virsh pool-list
- name: Run vagrant up
run: sudo vagrant up almalinux
- name: Prepare build infrastructure
run: |
# Install need packages
enable_repo=${{ env.dnf_crb_repo }}
sudo vagrant ssh almalinux -c "sudo dnf install -y --enablerepo=${enable_repo,,} ${{ env.need_pkgs }}"
# Create file-system and mount additional disk
sudo vagrant ssh almalinux -c "sudo mkfs.xfs -f /dev/vdb"
sudo vagrant ssh almalinux -c "sudo sh -c 'mkdir -p ${{ env.livemedia_resultdir }}; mount /dev/vdb ${{ env.livemedia_resultdir }}'"
# - name: Get kickstarts and the script
# run: |
# sudo vagrant ssh almalinux -c "sudo sh -c 'cp -a /vagrant/kickstarts ${{ env.livemedia_resultdir }}/; cp -a /vagrant/livemedia-creator.sh ${{ env.livemedia_resultdir }}/'"
- name: Build media
run: |
sudo vagrant ssh almalinux -c "sudo sh -c 'mkdir -p ${{ env.livemedia_resultdir }}/iso_${{ matrix.image_types}} ${{ env.livemedia_resultdir }}/logs/anaconda; touch ${{ env.livemedia_resultdir }}/iso_${{ matrix.image_types}}/${{ env.results_name }}.iso ${{ env.livemedia_resultdir }}/logs/livemedia.log ${{ env.livemedia_resultdir }}/logs/anaconda/packaging.log'"
# sudo vagrant ssh almalinux -c "sudo livemedia-creator --ks=${{ env.livemedia_resultdir }}/kickstarts/${{ env.kickstart }} --no-virt --resultdir ${{ env.livemedia_resultdir }}/iso_${{ matrix.image_types}} --project 'AlmaLinux Live' --make-iso --iso-only --iso-name '${{ env.results_name }}.iso' --releasever 9.${{ env.version_minor }} --volid '${{ env.volid }}' --nomacboot --logfile ${{ env.livemedia_resultdir }}/logs/livemedia.log --anaconda-arg='--product AlmaLinux'"
# sudo vagrant ssh almalinux -c "sudo bash /vagrant/livemedia-creator.sh"
# sudo vagrant ssh almalinux -c "sudo sh -c 'cd ${{ env.livemedia_resultdir }}/; tree'"
- name: Get media
if: inputs.store_as_artifact || inputs.upload_to_s3
id: get-media
run: |
sudo vagrant scp almalinux:${{ env.livemedia_resultdir }}/iso_${{ matrix.image_types}}/${{ env.results_name }}.iso ${{ env.results_path }}/
# Compute SHA256 digest for the .iso
cd ${{ env.results_path }} && sha256sum ${{ env.results_name }}.iso > ${{ env.results_name }}.iso.CHECKSUM
ls -la ${{ env.results_path }}
# - name: Collect livemedia-creator logs
# if: success() || failure()
# run: |
# sudo vagrant scp almalinux:${{ env.livemedia_resultdir }}/logs/*.log ${{ env.results_path }}/
- name: Collect and prepare logs
if: success() || failure()
run: |
# Pack and compress logs in the VM
sudo vagrant ssh almalinux -c "sudo sh -c 'cd ${{ env.livemedia_resultdir }}; tar -cvf ${{ env.results_name }}-logs.tar logs/'"
sudo vagrant ssh almalinux -c "sudo sh -c 'cd ${{ env.livemedia_resultdir }}; zstd -T0 -19 ${{ env.results_name }}-logs.tar -o ${{ env.results_name }}-logs.tar.zst'"
# Get long into the host
sudo vagrant scp almalinux:${{ env.livemedia_resultdir }}/${{ env.results_name }}-logs.tar* ${{ env.results_path }}/
# sudo vagrant scp almalinux:${{ env.livemedia_resultdir }}/${{ env.results_name }}-logs.tar.zst ${{ env.results_path }}/
- uses: actions/upload-artifact@v4
name: Store logs as artifact
id: logs-artifact
if: success() || failure()
with:
name: AlmaLinux-${{ inputs.version_major }}.${{ env.version_minor }}-x86_64-Live-${{ matrix.image_types }}-logs.tar.zip
path: ${{ env.results_path }}/*.tar
- uses: actions/upload-artifact@v4
name: Store CHECKSUM as artifact
id: checksum-artifact
if: steps.get-media.outcome == 'success' && inputs.store_as_artifact
with:
name: "${{ env.results_name }}.iso.CHECKSUM.zip"
path: ${{ env.results_path }}/${{ env.results_name }}.iso.CHECKSUM
- uses: actions/upload-artifact@v4
name: Store ISO as artifact
id: iso-artifact
if: steps.get-media.outcome == 'success' && inputs.store_as_artifact
with:
name: "${{ env.results_name }}.iso.zip"
compression-level: 1
path: ${{ env.results_path }}/${{ env.results_name }}.iso
- name: Configure AWS credentials
if: steps.get-media.outcome == 'success' && inputs.upload_to_s3
uses: aws-actions/[email protected]
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- uses: osiegmar/s3-publisher-action@v1
name: Publish to S3 bucket
if: steps.get-media.outcome == 'success' && inputs.upload_to_s3
with:
bucket: ${{ vars.AWS_BUCKET }}
prefix: "${{ env.date_stamp }}/"
dir: "${{ env.results_path }}"
includes: |
${{ env.results_name }}.iso
${{ env.results_name }}-logs.tar.zst
${{ env.results_name }}.iso.CHECKSUM
- name: Put object tagging with aws CLI
if: steps.get-media.outcome == 'success' && inputs.upload_to_s3
run: |
for object in ${{ env.results_name }}.iso ${{ env.results_name }}-logs.tar.zst ${{ env.results_name }}.iso.CHECKSUM; do
aws s3api put-object-tagging --bucket ${{ vars.AWS_BUCKET }} --key ${{ env.date_stamp }}/${object} --tagging 'TagSet={Key=public,Value=yes}'
done
- uses: actions/github-script@v7
if: steps.get-media.outcome == 'success' && inputs.upload_to_s3
name: Put AWS S3 download URLs
with:
result-encoding: string
script: |
core.summary
.addHeading('AWS S3 download URLs')
.addLink('${{ env.results_name }}.iso.CHECKSUM', 'https://${{ vars.AWS_BUCKET }}.s3-accelerate.dualstack.amazonaws.com/${{ env.date_stamp }}/${{ env.results_name }}.iso.CHECKSUM')
.addLink('${{ env.results_name }}.iso', 'https://${{ vars.AWS_BUCKET }}.s3-accelerate.dualstack.amazonaws.com/${{ env.date_stamp }}/${{ env.results_name }}.iso')
.addLink()'${{ env.results_name }}-logs.tar.zst', 'https://${{ vars.AWS_BUCKET }}.s3-accelerate.dualstack.amazonaws.com/${{ env.date_stamp }}/${{ env.results_name }}-logs.tar.zst')
.write()
- name: Send notification to Mattermost (AWS S3 files)
uses: mattermost/action-mattermost-notify@master
if: steps.get-media.outcome == 'success' && inputs.upload_to_s3 && inputs.notify_mattermost
with:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
MATTERMOST_CHANNEL: ${{ vars.MATTERMOST_CHANNEL }}
MATTERMOST_USERNAME: ${{ github.triggering_actor }}
TEXT: |
**AlmaLinux OS 9.${{ env.version_minor }} Live Media Build** `${{ env.date_stamp }}` generated by the GitHub [Action](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
**CHECKSUM(SHA256):** https://${{ vars.AWS_BUCKET }}.s3-accelerate.dualstack.amazonaws.com/${{ env.date_stamp }}/${{ env.results_name }}.iso.CHECKSUM
**ISO:**
- ${{ matrix.image_types }}: https://${{ vars.AWS_BUCKET }}.s3-accelerate.dualstack.amazonaws.com/${{ env.date_stamp }}/${{ env.results_name }}.iso
**Logs:**
- ${{ matrix.image_types }}: https://${{ vars.AWS_BUCKET }}.s3-accelerate.dualstack.amazonaws.com/${{ env.date_stamp }}/${{ env.results_name }}-logs.tar.zst
- name: Send notification to Mattermost (Artifacts)
uses: mattermost/action-mattermost-notify@master
if: steps.get-media.outcome == 'success' && inputs.store_as_artifact && inputs.notify_mattermost
with:
MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
MATTERMOST_CHANNEL: ${{ vars.MATTERMOST_CHANNEL }}
MATTERMOST_USERNAME: ${{ github.triggering_actor }}
TEXT: |
**AlmaLinux OS 9.${{ env.version_minor }} Live Media Build** `${{ env.date_stamp }}` generated by the GitHub [Action](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
**CHECKSUM(SHA256) [zipped]:** ${{ steps.checksum-artifact.outputs.artifact-url }}
**ISO [zipped]:**
- ${{ matrix.image_types }}: ${{ steps.iso-artifact.outputs.artifact-url }}
**Logs [zipped]:**
- ${{ matrix.image_types }}: ${{ steps.logs-artifact.outputs.artifact-url }}