Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 47 additions & 16 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
# Build a bootable image from a PR triggered by a "/build-image" comment or manually.
#
# Choose type of the image with these options:
# --boot.iso
# --boot.iso [variant] (Everything, Server; network installer)
# --live [variant] (Workstation, KDE, Xfce, Cinnamon, MATE, LXDE, LXQt, Sway, Budgie, i3)
# --updates.img
#
# If none of these is present, --boot.iso is assumed.
# If more are present at once, all variants are built.
# If --live is used without variant, Workstation is assumed.
# The default variants are Everything for --boot.iso and Workstation for --live.
#
# To use webui on boot.iso, add also:
# --webui
Expand All @@ -33,6 +33,14 @@ on:
types: [created]
# be able to start this action manually from a actions tab when needed
workflow_dispatch:
inputs:
boot_variant:
description: Boot ISO flavor (network installer)
type: choice
default: Everything
options:
- Everything
- Server

permissions:
contents: read
Expand Down Expand Up @@ -98,6 +106,7 @@ jobs:
# Do not use comment body directly in the shell command to avoid possible code injection.
env:
BODY: ${{ github.event.comment.body }}
DEFAULT_BOOT_VARIANT: ${{ inputs.boot_variant || 'Everything' }}
run: |
# extract first line and cut out the "/build-image" first word
ARGS=$(echo "$BODY" | sed -n '1 s/^[^ ]* *//p' | sed 's/[[:space:]]*$//')
Expand All @@ -107,6 +116,35 @@ jobs:
echo "adding implicit --boot.iso, arguments now are: $ARGS"
fi

read -r -a ARG_WORDS <<< "$ARGS"
iso_variant() {
local option="$1" default="$2"
shift 2
while (($#)); do
if [[ "$1" == "$option" ]]; then
local next="${2:-}"
if [[ -n "$next" && "$next" != --* ]]; then
printf '%s\n' "$next"
return
fi
break
fi
shift
done
printf '%s\n' "$default"
}

BOOT_VARIANT=$(iso_variant --boot.iso "$DEFAULT_BOOT_VARIANT" "${ARG_WORDS[@]}")
LIVE_VARIANT=$(iso_variant --live Workstation "${ARG_WORDS[@]}")
case "$BOOT_VARIANT" in
Everything|Server) ;;
*) echo "::error::Unsupported boot variant (expected Everything or Server)"; exit 1 ;;
esac
if ! [[ "$LIVE_VARIANT" =~ ^[[:alnum:]]+$ ]]; then
echo "::error::Invalid Live ISO variant"
exit 1
fi

# Extract --image parameter if present
IMAGE_TAG=""
if [[ "$ARGS" == *"--image"* ]]; then
Expand All @@ -122,17 +160,6 @@ jobs:
CI_TAG=$(make -f Makefile.am -s print-CI_TAG)
fi

# Extract --live variant (Workstation, KDE, Xfce, etc.)
LIVE_VARIANT="Workstation"
if [[ "$ARGS" == *"--live"* ]]; then
# Extract variant after --live (first word that doesn't start with --)
EXTRACTED=$(echo "$ARGS" | sed -n 's/.*--live[[:space:]]\+\([A-Za-z]*\).*/\1/p')
if [[ -n "$EXTRACTED" ]]; then
LIVE_VARIANT="$EXTRACTED"
fi
fi
echo "live_variant=${LIVE_VARIANT}"

# Extract --anaconda-webui-pr number if present
ANACONDA_WEBUI_PR=""
if [[ "$ARGS" == *"--anaconda-webui-pr"* ]]; then
Expand All @@ -157,6 +184,7 @@ jobs:
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
echo "ci_tag=${CI_TAG}" >> $GITHUB_OUTPUT
echo "live_variant=${LIVE_VARIANT}" >> $GITHUB_OUTPUT
echo "boot_variant=${BOOT_VARIANT}" >> $GITHUB_OUTPUT
echo "anaconda_webui_pr=${ANACONDA_WEBUI_PR}" >> $GITHUB_OUTPUT
echo "cockpit_pr=${COCKPIT_PR}" >> $GITHUB_OUTPUT

Expand Down Expand Up @@ -207,6 +235,7 @@ jobs:
args: ${{ steps.parse_args.outputs.args }}
ci_tag: ${{ steps.parse_args.outputs.ci_tag }}
live_variant: ${{ steps.parse_args.outputs.live_variant }}
boot_variant: ${{ steps.parse_args.outputs.boot_variant }}
anaconda_webui_pr: ${{ steps.parse_args.outputs.anaconda_webui_pr }}
cockpit_pr: ${{ steps.parse_args.outputs.cockpit_pr }}
image_description: ${{ steps.image_description.outputs.image_description }}
Expand All @@ -221,6 +250,7 @@ jobs:
STATUS_NAME: boot-iso
ISO_BUILD_CONTAINER_NAME: 'quay.io/rhinstaller/anaconda-iso-creator'
CI_TAG: ${{ needs.pr-info.outputs.ci_tag }}
FEDORA_VARIANT: ${{ needs.pr-info.outputs.boot_variant }}
steps:
# we post statuses manually as this does not run from a pull_request event
# https://developer.github.com/v3/repos/statuses/#create-a-status
Expand Down Expand Up @@ -270,13 +300,14 @@ jobs:
fi
# /var/tmp tmpfs speeds up the build and avoids https://bugzilla.redhat.com/show_bug.cgi?id=1906364
sudo podman run -i --rm --privileged --env CI_TAG=$CI_TAG \
--env FEDORA_VARIANT \
--tmpfs /var/tmp:rw,mode=1777 \
-v `pwd`/anaconda_rpms:/anaconda-rpms:ro \
-v `pwd`/images:/images:z \
$WEBUI_OPTIONAL_ARG \
$WEBUI_PR_ARGS \
$ISO_BUILD_CONTAINER_NAME:$CI_TAG
mv images/boot.iso "images/${{ needs.pr-info.outputs.image_description }}-boot.iso"
mv images/boot.iso "images/${{ needs.pr-info.outputs.image_description }}-${FEDORA_VARIANT}-boot.iso"

- name: Collect logs
if: always()
Expand All @@ -289,7 +320,7 @@ jobs:
- name: Upload image
uses: actions/upload-artifact@v7
with:
name: boot.iso image for ${{ needs.pr-info.outputs.image_description }}
name: boot.iso (${{ needs.pr-info.outputs.boot_variant }}) image for ${{ needs.pr-info.outputs.image_description }}
path: |
images/*.iso

Expand Down Expand Up @@ -450,7 +481,7 @@ jobs:
if [[ "${{ needs.pr-info.outputs.args }}" == *"--boot.iso"* ]] ; then
# <job>.result can be success, failure, cancelled, or skipped
# https://docs.github.com/en/actions/learn-github-actions/contexts#jobs-context
echo -e "- \`boot.iso\`: ${{ needs.boot-iso.result }}\n" >> comment.txt
echo -e "- \`boot.iso\` (${{ needs.pr-info.outputs.boot_variant }}): ${{ needs.boot-iso.result }}\n" >> comment.txt
fi
if [[ "${{ needs.pr-info.outputs.args }}" == *"--live"* ]] ; then
echo -e "- Live (${{ needs.pr-info.outputs.live_variant }}): ${{ needs.live-iso.result }}\n" >> comment.txt
Expand Down
63 changes: 47 additions & 16 deletions .github/workflows/build-image.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# Build a bootable image from a PR triggered by a "/build-image" comment or manually.
#
# Choose type of the image with these options:
# --boot.iso
# --boot.iso [variant] (Everything, Server; network installer)
# --live [variant] (Workstation, KDE, Xfce, Cinnamon, MATE, LXDE, LXQt, Sway, Budgie, i3)
# --updates.img
#
# If none of these is present, --boot.iso is assumed.
# If more are present at once, all variants are built.
# If --live is used without variant, Workstation is assumed.
# The default variants are Everything for --boot.iso and Workstation for --live.
#
# To use webui on boot.iso, add also:
# --webui
Expand All @@ -27,6 +27,14 @@ on:
types: [created]
# be able to start this action manually from a actions tab when needed
workflow_dispatch:
inputs:
boot_variant:
description: Boot ISO flavor (network installer)
type: choice
default: Everything
options:
- Everything
- Server

permissions:
contents: read
Expand Down Expand Up @@ -92,6 +100,7 @@ jobs:
# Do not use comment body directly in the shell command to avoid possible code injection.
env:
BODY: ${{ github.event.comment.body }}
DEFAULT_BOOT_VARIANT: ${{ inputs.boot_variant || 'Everything' }}
run: |
# extract first line and cut out the "/build-image" first word
ARGS=$(echo "$BODY" | sed -n '1 s/^[^ ]* *//p' | sed 's/[[:space:]]*$//')
Expand All @@ -101,6 +110,35 @@ jobs:
echo "adding implicit --boot.iso, arguments now are: $ARGS"
fi

read -r -a ARG_WORDS <<< "$ARGS"
iso_variant() {
local option="$1" default="$2"
shift 2
while (($#)); do
if [[ "$1" == "$option" ]]; then
local next="${2:-}"
if [[ -n "$next" && "$next" != --* ]]; then
printf '%s\n' "$next"
return
fi
break
fi
shift
done
printf '%s\n' "$default"
}

BOOT_VARIANT=$(iso_variant --boot.iso "$DEFAULT_BOOT_VARIANT" "${ARG_WORDS[@]}")
LIVE_VARIANT=$(iso_variant --live Workstation "${ARG_WORDS[@]}")
case "$BOOT_VARIANT" in
Everything|Server) ;;
*) echo "::error::Unsupported boot variant (expected Everything or Server)"; exit 1 ;;
esac
if ! [[ "$LIVE_VARIANT" =~ ^[[:alnum:]]+$ ]]; then
echo "::error::Invalid Live ISO variant"
exit 1
fi

# Extract --image parameter if present
IMAGE_TAG=""
if [[ "$ARGS" == *"--image"* ]]; then
Expand All @@ -116,17 +154,6 @@ jobs:
CI_TAG=$(make -f Makefile.am -s print-CI_TAG)
fi

# Extract --live variant (Workstation, KDE, Xfce, etc.)
LIVE_VARIANT="Workstation"
if [[ "$ARGS" == *"--live"* ]]; then
# Extract variant after --live (first word that doesn't start with --)
EXTRACTED=$(echo "$ARGS" | sed -n 's/.*--live[[:space:]]\+\([A-Za-z]*\).*/\1/p')
if [[ -n "$EXTRACTED" ]]; then
LIVE_VARIANT="$EXTRACTED"
fi
fi
echo "live_variant=${LIVE_VARIANT}"

# Extract --anaconda-webui-pr number if present
ANACONDA_WEBUI_PR=""
if [[ "$ARGS" == *"--anaconda-webui-pr"* ]]; then
Expand All @@ -151,6 +178,7 @@ jobs:
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
echo "ci_tag=${CI_TAG}" >> $GITHUB_OUTPUT
echo "live_variant=${LIVE_VARIANT}" >> $GITHUB_OUTPUT
echo "boot_variant=${BOOT_VARIANT}" >> $GITHUB_OUTPUT
echo "anaconda_webui_pr=${ANACONDA_WEBUI_PR}" >> $GITHUB_OUTPUT
echo "cockpit_pr=${COCKPIT_PR}" >> $GITHUB_OUTPUT

Expand Down Expand Up @@ -201,6 +229,7 @@ jobs:
args: ${{ steps.parse_args.outputs.args }}
ci_tag: ${{ steps.parse_args.outputs.ci_tag }}
live_variant: ${{ steps.parse_args.outputs.live_variant }}
boot_variant: ${{ steps.parse_args.outputs.boot_variant }}
anaconda_webui_pr: ${{ steps.parse_args.outputs.anaconda_webui_pr }}
cockpit_pr: ${{ steps.parse_args.outputs.cockpit_pr }}
image_description: ${{ steps.image_description.outputs.image_description }}
Expand All @@ -215,6 +244,7 @@ jobs:
STATUS_NAME: boot-iso
ISO_BUILD_CONTAINER_NAME: 'quay.io/rhinstaller/anaconda-iso-creator'
CI_TAG: ${{ needs.pr-info.outputs.ci_tag }}
FEDORA_VARIANT: ${{ needs.pr-info.outputs.boot_variant }}
steps:
# we post statuses manually as this does not run from a pull_request event
# https://developer.github.com/v3/repos/statuses/#create-a-status
Expand Down Expand Up @@ -264,13 +294,14 @@ jobs:
fi
# /var/tmp tmpfs speeds up the build and avoids https://bugzilla.redhat.com/show_bug.cgi?id=1906364
sudo podman run -i --rm --privileged --env CI_TAG=$CI_TAG \
--env FEDORA_VARIANT \
--tmpfs /var/tmp:rw,mode=1777 \
-v `pwd`/anaconda_rpms:/anaconda-rpms:ro \
-v `pwd`/images:/images:z \
$WEBUI_OPTIONAL_ARG \
$WEBUI_PR_ARGS \
$ISO_BUILD_CONTAINER_NAME:$CI_TAG
mv images/boot.iso "images/${{ needs.pr-info.outputs.image_description }}-boot.iso"
mv images/boot.iso "images/${{ needs.pr-info.outputs.image_description }}-${FEDORA_VARIANT}-boot.iso"

- name: Collect logs
if: always()
Expand All @@ -283,7 +314,7 @@ jobs:
- name: Upload image
uses: actions/upload-artifact@v7
with:
name: boot.iso image for ${{ needs.pr-info.outputs.image_description }}
name: boot.iso (${{ needs.pr-info.outputs.boot_variant }}) image for ${{ needs.pr-info.outputs.image_description }}
path: |
images/*.iso

Expand Down Expand Up @@ -444,7 +475,7 @@ jobs:
if [[ "${{ needs.pr-info.outputs.args }}" == *"--boot.iso"* ]] ; then
# <job>.result can be success, failure, cancelled, or skipped
# https://docs.github.com/en/actions/learn-github-actions/contexts#jobs-context
echo -e "- \`boot.iso\`: ${{ needs.boot-iso.result }}\n" >> comment.txt
echo -e "- \`boot.iso\` (${{ needs.pr-info.outputs.boot_variant }}): ${{ needs.boot-iso.result }}\n" >> comment.txt
fi
if [[ "${{ needs.pr-info.outputs.args }}" == *"--live"* ]] ; then
echo -e "- Live (${{ needs.pr-info.outputs.live_variant }}): ${{ needs.live-iso.result }}\n" >> comment.txt
Expand Down
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ container-iso-build:

mkdir -p result/iso
sudo $(CONTAINER_ENGINE) run --env CI_TAG=$(CI_TAG) \
$(if $(FEDORA_VARIANT),--env FEDORA_VARIANT="$(FEDORA_VARIANT)") \
$(if $(ANACONDA_WEBUI_PR),--env ANACONDA_WEBUI_PR="$$ANACONDA_WEBUI_PR") \
$(if $(COCKPIT_PR),--env COCKPIT_PR="$$COCKPIT_PR") \
--rm \
Expand Down
32 changes: 23 additions & 9 deletions dockerfile/anaconda-iso-creator/image-builder-build
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@

set -eux

# Select the Fedora network installer flavor (also used by the Web UI build).
: "${FEDORA_VARIANT:=Everything}"
case "$FEDORA_VARIANT" in
Everything)
IMAGE_BUILDER_TYPE="everything-network-installer"
ISO_VARIANT_LABEL="E"
;;
Server)
IMAGE_BUILDER_TYPE="server-network-installer"
ISO_VARIANT_LABEL="S"
;;
*)
echo "Unsupported FEDORA_VARIANT: $FEDORA_VARIANT (expected Everything or Server)" >&2
exit 1
;;
esac

# pre-create loop devices manually. In the container you can't use losetup for that.
mknod -m 0660 /dev/loop0 b 7 0 2> /dev/null || true
mknod -m 0660 /dev/loop1 b 7 1 2> /dev/null || true
Expand Down Expand Up @@ -69,7 +86,7 @@ fi
# regardless of whether CI_TAG says "fedora-rawhide" or "fedora-<N>".
IMAGE_BUILDER_DISTRO="fedora-${VERSION_ID}"

# Match Fedora's pungi-fedora Everything installer label, including the
# Match Fedora's pungi-fedora installer label for the selected variant, including the
# "dvd" marker used by libosinfo to identify installation media.
# https://forge.fedoraproject.org/releng/pungi-fedora/src/branch/main/fedora.conf
ISO_VOLID_VERSION="$VERSION_ID"
Expand All @@ -83,7 +100,7 @@ fi
BLUEPRINT=/tmp/installer-blueprint.toml
cat > "$BLUEPRINT" <<EOF
[customizations.iso]
volume_id = "Fedora-E-dvd-\$arch-${ISO_VOLID_VERSION}"
volume_id = "Fedora-${ISO_VARIANT_LABEL}-dvd-\$arch-${ISO_VOLID_VERSION}"
EOF

if [ "${IMAGE_BUILDER_WEBUI:-0}" = "1" ]; then
Expand All @@ -97,13 +114,10 @@ EOF
fi

mkdir -p output
# "everything-network-installer" is Fedora's generic, interactive,
# network-install Anaconda boot.iso - the image-builder equivalent of what
# lorax's runtime-install.tmpl built (the upstream distrodef literally notes
# "Based on lorax runtime-install.tmpl"). Not to be confused with the
# "network-installer" image_func name used internally, or the RHEL/CentOS
# Stream type of the same latter name.
image-builder build everything-network-installer \
# Both flavors are interactive network installers. The Server type also
# includes fedora-release-server to select Anaconda's Server configuration.
echo "Building $FEDORA_VARIANT boot.iso using $IMAGE_BUILDER_TYPE (Web UI: ${IMAGE_BUILDER_WEBUI:-0})"
image-builder build "$IMAGE_BUILDER_TYPE" \
--distro "$IMAGE_BUILDER_DISTRO" \
--blueprint "$BLUEPRINT" \
"${LOCAL_REPO_ARGS[@]}" \
Expand Down
Loading
Loading