Skip to content

image-based

image-based #93

Workflow file for this run

name: Build and Deploy k4all
on:
pull_request:
branches:
- image-based
paths-ignore:
- "**/*.md"
- "**/*.txt"
push:
branches:
- image-based
paths-ignore:
- "**/*.md"
- "**/*.txt"
workflow_dispatch:
inputs:
changelog:
description: 'Brief description of changes in this build'
required: false
env:
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
IMAGE_NAME: k4all-image
K4ALL_VERSION: testing
ARCH: x86_64
VARIANT: CoreOS
ISO_NAME: k4all-${{ github.ref_name }}-testing.iso
RAW_NAME: k4all-${{ github.ref_name }}-testing.raw
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name || github.run_id }}
cancel-in-progress: true
jobs:
# build-and-push-image:
# name: Build and Push Fedora CoreOS Image
# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# id-token: write
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v4
# - name: Set Up QEMU
# uses: docker/setup-qemu-action@v2
# - name: Set Up Docker Buildx
# uses: docker/setup-buildx-action@v2
# - name: Log in to GitHub Container Registry
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Build and Push Image
# uses: docker/build-push-action@v4
# with:
# context: .
# file: ./Containerfile
# platforms: linux/amd64
# push: true
# tags: |
# ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
# ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
build-iso:
name: Build Bootable ISO
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Create Output Directory
run: |
mkdir -p output
mkdir -p bootfiles
- name: Download Boot Files
run: |
# Base URL for raw files
BASE_URL="https://raw.githubusercontent.com/Tomas-M/linux-live/e51c6b7/bootfiles"
# Download required files
wget -O bootfiles/isolinux.bin "$BASE_URL/isolinux.bin"
wget -O bootfiles/vesamenu.c32 "$BASE_URL/vesamenu.c32"
wget -O bootfiles/ldlinux.c32 "$BASE_URL/ldlinux.c32"
wget -O bootfiles/libcom32.c32 "$BASE_URL/libcom32.c32"
wget -O bootfiles/libutil.c32 "$BASE_URL/libutil.c32"
wget -O bootfiles/mbr.bin "$BASE_URL/mbr.bin"
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install -y podman xorriso genisoimage fdisk kpartx ostree tree
- name: Build Raw Image
run: |
sudo podman pull ghcr.io/gpillon/k4all-image
sudo podman run \
--rm \
--privileged \
--pull=newer \
--security-opt label=type:unconfined_t \
-v ./output:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--type raw \
--rootfs xfs \
--local ghcr.io/gpillon/k4all-image
- name: Move RAW Image
run: |
sudo mv output/image/disk.raw output/${{ env.RAW_NAME }}
sudo chown 1000:1000 output/${{ env.RAW_NAME }}
- name: Convert Raw to ISO
run: |
# Set up loop device and get device name
LOOP_DEV=$(sudo losetup --show -f output/${{ env.RAW_NAME }})
echo "Using loop device: $LOOP_DEV"
# Set up partition mapping
sudo kpartx -av $LOOP_DEV
# Create temporary mount points
sudo mkdir -p /mnt/raw /mnt/boot /mnt/efi
# Find the root and boot partitions
ROOT_PART=$(echo $LOOP_DEV | sed 's/\/dev\//\/dev\/mapper\//')
ROOT_PART="${ROOT_PART}p4" # root is partition 4
BOOT_PART="${ROOT_PART%p4}p3" # boot is partition 3
# Mount partitions
sudo mount $ROOT_PART /mnt/raw
sudo mount $BOOT_PART /mnt/boot
# Create ISO directory structure
mkdir -p isofs/{isolinux,EFI/BOOT}
# Copy boot files from OSTree directory with exact filenames
sudo cp "/mnt/boot/ostree/default-717f957fb4680546cce36bc1c5e633abdbf5e4ecb6e99e5665df3c00a56088fa/vmlinuz-6.11.6-300.fc41.x86_64" isofs/isolinux/vmlinuz
sudo cp "/mnt/boot/ostree/default-717f957fb4680546cce36bc1c5e633abdbf5e4ecb6e99e5665df3c00a56088fa/initramfs-6.11.6-300.fc41.x86_64.img" isofs/isolinux/initrd
# Copy boot files from linux-live
cp bootfiles/isolinux.bin isofs/isolinux/
cp bootfiles/vesamenu.c32 isofs/isolinux/
cp bootfiles/ldlinux.c32 isofs/isolinux/
cp bootfiles/libcom32.c32 isofs/isolinux/
cp bootfiles/libutil.c32 isofs/isolinux/
# Create isolinux configuration
cat > isofs/isolinux/isolinux.cfg << EOF
UI vesamenu.c32
MENU TITLE Boot Menu
MENU COLOR border 30;44 #40ffffff #a0000000 std
MENU COLOR title 1;36;44 #9033ccff #a0000000 std
MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all
MENU COLOR unsel 37;44 #50ffffff #a0000000 std
MENU COLOR help 37;40 #c0ffffff #a0000000 std
MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std
MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
MENU COLOR msg07 37;40 #90ffffff #a0000000 std
MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
MENU CLEAR
MENU IMMEDIATE
TIMEOUT 300
LABEL linux
MENU LABEL Start K4All Linux
MENU DEFAULT
KERNEL vmlinuz
APPEND initrd=initrd root=live:CDLABEL=BOOTC-ISO rd.live.image quiet console=tty0 console=ttyS0,115200n8
EOF
# Create ISO
sudo xorriso -as mkisofs \
-iso-level 3 \
-full-iso9660-filenames \
-volid "BOOTC-ISO" \
-eltorito-boot isolinux/isolinux.bin \
-eltorito-catalog isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-isohybrid-mbr bootfiles/mbr.bin \
-output output/${{ env.ISO_NAME }} \
isofs
# Cleanup
sudo umount /mnt/boot
sudo umount /mnt/raw
sudo kpartx -d $LOOP_DEV
sudo losetup -d $LOOP_DEV
sudo rm -rf isofs /mnt/{raw,boot,efi}
- name: Upload ISO to Job Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.IMAGE_NAME }}-${{ github.ref_name }}
path: output/${{ env.ISO_NAME }}
if-no-files-found: error
retention-days: 7
overwrite: true
generate-release:
name: Generate Release
needs: build-iso
permissions:
contents: write # Add this permission for release creation
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Get Branch Name
id: get-branch
run: |
BRANCH_NAME=${GITHUB_REF##*/}
echo "branch=${BRANCH_NAME}" >> $GITHUB_OUTPUT
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.IMAGE_NAME }}-${{ steps.get-branch.outputs.branch }}
path: ./artifacts
- name: List Contents
run: |
ls -la ./artifacts
echo "Contents of artifacts directory:"
find ./artifacts -type f
- name: Generate Changelog
id: generate-changelog
run: |
echo "This release was generated for branch ${{ steps.get-branch.outputs.branch }}" > changelog.md
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: Release ${{ steps.get-branch.outputs.branch }}
tag_name: ${{ steps.get-branch.outputs.branch }}
body_path: ./changelog.md
make_latest: ${{ steps.get-branch.outputs.branch == 'main' }}
prerelease: ${{ steps.get-branch.outputs.branch != 'main' }}
files: |
./artifacts/${{ env.ISO_NAME }}
generate-release:
name: Generate Release
needs: build-iso
permissions:
contents: write # Add this permission for release creation
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Get Branch Name
id: get-branch
run: |
BRANCH_NAME=${GITHUB_REF##*/}
echo "branch=${BRANCH_NAME}" >> $GITHUB_OUTPUT
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.IMAGE_NAME }}-${{ steps.get-branch.outputs.branch }}
path: ./artifacts
- name: List Contents
run: |
ls -la ./artifacts
echo "Contents of artifacts directory:"
find ./artifacts -type f
- name: Generate Changelog
id: generate-changelog
run: |
echo "This release was generated for branch ${{ steps.get-branch.outputs.branch }}" > changelog.md
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: Release ${{ steps.get-branch.outputs.branch }}
tag_name: ${{ steps.get-branch.outputs.branch }}
body_path: ./changelog.md
make_latest: ${{ steps.get-branch.outputs.branch == 'main' }}
prerelease: ${{ steps.get-branch.outputs.branch != 'main' }}
files: |
./artifacts/${{ env.ISO_NAME }}