🏡 index : quine-global-labs/mirror-ublue-os-titanoboa.git

name: Titanoboa LiveCD ISO builder
description: >-
  Create LiveCDs of a bootc container image.
  The resulting iso will be placed at `output.iso`.
inputs:
  image-ref:
    description: Reference to the bootc container image to build the ISO from.
    required: true
  iso-dest:
    description: Where the iso will be placed
    required: false
    default: ${{ github.workspace }}/output.iso
outputs:
  iso-dest:
    description: Where the iso was be placed
    value: ${{ steps.generate-iso.outputs.iso_dest }}

runs:
  using: composite
  steps:
    - name: Generate iso
      id: generate-iso
      env:
        DESTINATION_PATH: ${{ inputs.iso-dest }}
        TITANOBOA_CTR_IMAGE: ${{ inputs.image-ref }}
      shell: bash
      run: |
        set -euxo pipefail
        cd "$GITHUB_ACTION_PATH" || exit 1

        # Build ISO
        ISO_FILENAME="$(env TITANOBOA_CTR_IMAGE="$TITANOBOA_CTR_IMAGE" "$GITHUB_ACTION_PATH"/main.sh)"

        # Fix iso file permisions
        sudo chown $(id -u):$(id -g) "$ISO_FILENAME"

        # Move iso to iso-dest
        dest="$(realpath --relative-base="${GITHUB_WORKSPACE}" "${DESTINATION_PATH}")"
        dest="$(realpath -m $dest)"
        mkdir -p "$(dirname "$dest")"
        mv "$ISO_FILENAME" "$dest"
        echo "iso_dest=$dest" >> "$GITHUB_OUTPUT"

    - name: Check the iso is there
      shell: bash
      env:
        DEST_ISO: ${{ steps.generate-iso.outputs.iso_dest }}
      run: |
        [[ -f "${DEST_ISO}" ]] || {
          echo "::error:Iso file does not exist at ${DEST_ISO}"
          exit 1
        }