Compare commits
8
Commits
main
...
Ubuntu26.04
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da7448d814 | ||
|
|
7f612f8233 | ||
|
|
94755aa890 | ||
|
|
e05c079858 | ||
|
|
286e79ddab | ||
|
|
4a88c9568a | ||
|
|
d329080765 | ||
|
|
021b9851bd |
@@ -1,6 +1,10 @@
|
||||
name: build-image
|
||||
on: [push]
|
||||
|
||||
env:
|
||||
UBUNTU_VERSION: '26.04' # Resolute
|
||||
UBUNTU_SOURCE_IMAGE: https://st.itch.fyi/api/share/olYwWjZ17e?mode=download
|
||||
|
||||
jobs:
|
||||
semrel_dryrun:
|
||||
name: Semantic Release (Dry-run)
|
||||
@@ -49,9 +53,8 @@ jobs:
|
||||
run: |
|
||||
apt-get update && \
|
||||
apt-get install -y \
|
||||
linux-image-generic \
|
||||
linux-modules-extra-$(uname -r) \
|
||||
linux-headers-generic
|
||||
linux-generic
|
||||
# linux-modules-extra-$(uname -r) \
|
||||
|
||||
mkdir -p \
|
||||
$PWD/ubuntu-vm \
|
||||
@@ -59,11 +62,10 @@ jobs:
|
||||
- name: Retrieve source Ubuntu image
|
||||
run: |
|
||||
curl -L \
|
||||
https://sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2024.04/ubuntu-24.04-server-cloudimg-amd64.img \
|
||||
-o ubuntu-vm/ubuntu-24.04-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img \
|
||||
-u ${{ secrets.REPO_USERNAME }}:${{ secrets.REPO_PASSWORD }}
|
||||
${{ env.UBUNTU_SOURCE_IMAGE }} \
|
||||
-o ubuntu-vm/ubuntu-${{ env.UBUNTU_VERSION }}-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img
|
||||
|
||||
qemu-img resize ubuntu-vm/ubuntu-24.04-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img +5G
|
||||
qemu-img resize ubuntu-vm/ubuntu-${{ env.UBUNTU_VERSION }}-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img +5G
|
||||
- name: Generate seed ISO
|
||||
run: |
|
||||
envsubst < cloud-init/user-data.template > cloud-init/user-data
|
||||
@@ -86,7 +88,7 @@ jobs:
|
||||
-m 3072 \
|
||||
-smp 2 \
|
||||
-cpu host \
|
||||
-drive file=ubuntu-vm/ubuntu-24.04-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img,if=virtio,format=qcow2 \
|
||||
-drive file=ubuntu-vm/ubuntu-${{ env.UBUNTU_VERSION }}-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img,if=virtio,format=qcow2 \
|
||||
-drive file=ubuntu-vm/seed.iso,format=raw,media=cdrom \
|
||||
-nographic \
|
||||
-net nic \
|
||||
@@ -95,40 +97,67 @@ jobs:
|
||||
-chardev socket,path=qga.sock,server=on,wait=off,id=qga0 \
|
||||
-device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0
|
||||
|
||||
if ! guestfish --ro -a ubuntu-vm/ubuntu-24.04-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img -i stat /var/log/template-generation-success; then
|
||||
if ! guestfish --ro -a ubuntu-vm/ubuntu-${{ env.UBUNTU_VERSION }}-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img -i stat /var/log/template-generation-success; then
|
||||
echo "VM provisioning encountered errors - exiting"
|
||||
exit 1
|
||||
fi
|
||||
- name: Compress image file
|
||||
id: compress_image
|
||||
run: |
|
||||
virt-sparsify --compress \
|
||||
ubuntu-vm/ubuntu-24.04-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img \
|
||||
ubuntu-vm/ubuntu-24.04-rke2-v${{ needs.semrel_dryrun.outputs.version }}-compacted.img
|
||||
--check-tmpdir ignore \
|
||||
ubuntu-vm/ubuntu-${{ env.UBUNTU_VERSION }}-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img \
|
||||
ubuntu-vm/ubuntu-${{ env.UBUNTU_VERSION }}-rke2-v${{ needs.semrel_dryrun.outputs.version }}-compacted.img
|
||||
|
||||
rm ubuntu-vm/ubuntu-${{ env.UBUNTU_VERSION }}-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img
|
||||
|
||||
echo "image_path=ubuntu-vm/ubuntu-${{ env.UBUNTU_VERSION }}-rke2-v${{ needs.semrel_dryrun.outputs.version }}-compacted.img" | tee -a "$GITHUB_OUTPUT"
|
||||
- name: Check for existing resources
|
||||
run: |
|
||||
curl -fsSL -X GET \
|
||||
http://nextexplorer.nextexplorer.svc.cluster.local:3000/api/browse/Storage/Repository/rel/ || true
|
||||
curl -ksS -X GET \
|
||||
https://lab-hv-vip.bessems.lan/v1/harvesterhci.io.virtualmachineimages || true
|
||||
- name: Upload image file
|
||||
run: |
|
||||
REPO_TOKEN=$(curl -fsSL -X POST \
|
||||
http://filebrowser.filebrowser.svc.cluster.local:80/api/login \
|
||||
set -x
|
||||
REPO_TOKEN=$(curl -fsiSL -X POST \
|
||||
http://nextexplorer.nextexplorer.svc.cluster.local:3000/api/auth/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username": "admin", "password": "${{ secrets.REPO_PASSWORD }}"}' \
|
||||
-d '{"email": "${{ secrets.REPO_USERNAME }}", "password": "${{ secrets.REPO_PASSWORD }}"}' | \
|
||||
grep -oP 'connect\.sid=[^;]+' | head -n 1
|
||||
)
|
||||
curl -fsSL -X POST \
|
||||
http://filebrowser.filebrowser.svc.cluster.local:80/api/resources/rel/ubuntu-24.04-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img?override=true \
|
||||
--header "X-Auth: $REPO_TOKEN" \
|
||||
--upload-file "ubuntu-vm/ubuntu-24.04-rke2-v${{ needs.semrel_dryrun.outputs.version }}-compacted.img"
|
||||
|
||||
curl -ksS -X PUT "https://lab-hv-vip.bessems.lan/v1/harvesterhci.io.virtualmachineimages" \
|
||||
-H "Authorization: Bearer ${{ secrets.HV_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @- <<EOF
|
||||
FILE_PATH="${{ steps.compress_image.outputs.image_path }}"
|
||||
FILE_NAME="$(basename "$FILE_PATH" | sed 's/-compacted//')"
|
||||
|
||||
curl -fsSL -X POST \
|
||||
http://nextexplorer.nextexplorer.svc.cluster.local:3000/api/upload \
|
||||
--header "Cookie: $REPO_TOKEN" \
|
||||
--form "uploadTo=/Storage/Repository/rel" \
|
||||
--form "filedata=@${FILE_PATH};filename=${FILE_NAME}"
|
||||
SHARE_URL=$(curl -fsSL -X POST \
|
||||
http://nextexplorer.nextexplorer.svc.cluster.local:3000/api/shares \
|
||||
--header "Content-Type: application/json" \
|
||||
--header "Cookie: $REPO_TOKEN" \
|
||||
-d '{"sourcePath":"Storage/Repository/rel/${FILE_NAME}"}' | \
|
||||
jq -r '.directFileUrl'
|
||||
)
|
||||
|
||||
curl -ksS -X POST \
|
||||
https://lab-hv-vip.bessems.lan/v1/harvesterhci.io.virtualmachineimages \
|
||||
--header "Authorization: Bearer ${{ secrets.HV_TOKEN }}" \
|
||||
--header "Content-Type: application/json" \
|
||||
-d @- <<EOF
|
||||
{
|
||||
"type": "harvesterhci.io.virtualmachineimage",
|
||||
"metadata": {
|
||||
"namespace": "default"
|
||||
},
|
||||
"spec": {
|
||||
"displayName": "ubuntu-24.04-rke2-v${{ needs.semrel_dryrun.outputs.version }}",
|
||||
"displayName": "$FILE_NAME",
|
||||
"sourceType": "download",
|
||||
"url": "https://${{ secrets.REPO_USERNAME }}:${{ secrets.REPO_PASSWORD }}@sn.itch.fyi/Repository/rel/ubuntu-24.04-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img"
|
||||
"url": "$SHARE_URL?mode=download"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user