image-based #78
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
# needs: build-and-push-image | |
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 | |
- name: Install required packages | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y podman xorriso genisoimage | |
- 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: Configure Loop Devices | |
run: | | |
sudo modprobe loop | |
sudo lsmod | grep loop | |
sudo ls output/ | |
- name: Convert Raw to ISO | |
run: | | |
# First, create a temporary mount point | |
sudo mkdir -p /mnt/raw | |
# Mount the raw image | |
sudo mount -o loop output/${{ env.RAW_NAME }} /mnt/raw | |
# Create ISO directory structure | |
mkdir -p isofs/isolinux | |
# Copy the necessary files from the raw image | |
sudo cp -r /mnt/raw/boot/vmlinuz* isofs/isolinux/vmlinuz | |
sudo cp -r /mnt/raw/boot/initramfs* isofs/isolinux/initrd | |
# Create isolinux configuration | |
cat > isofs/isolinux/isolinux.cfg << EOF | |
DEFAULT linux | |
LABEL linux | |
KERNEL vmlinuz | |
APPEND initrd=initrd root=/dev/sda3 console=tty0 console=ttyS0,115200n8 | |
EOF | |
# Create the ISO | |
genisoimage -o output/${{ env.ISO_NAME }} \ | |
-b isolinux/isolinux.bin \ | |
-c isolinux/boot.cat \ | |
-no-emul-boot \ | |
-boot-load-size 4 \ | |
-boot-info-table \ | |
-R -J -v -T isofs/ | |
# Cleanup | |
sudo umount /mnt/raw | |
sudo rm -rf isofs /mnt/raw | |
- 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 | |
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: Generate Changelog | |
id: generate-changelog | |
run: | | |
echo "This release was generated for branch ${{ steps.get-branch.outputs.branch }}" > changelog.md | |
- name: Create or Update Release | |
uses: softprops/action-gh-release@v2 | |
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' }} | |
- name: Upload ISO to Release | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: ./artifacts/${{ env.ISO_NAME }} | |
asset_name: ${{ env.ISO_NAME }} | |
content_type: application/octet-stream |