From 4b84da46d0aac56fe84109c425e70207439c2a7a Mon Sep 17 00:00:00 2001 From: Robert Sturla Date: Fri, 9 Aug 2024 08:44:14 +0100 Subject: [PATCH] Build reusable workflow rather than action --- .github/actions/build-iso/action.yml | 1 + .github/workflows/_build-iso.yml | 101 +++++++++++++++++++++++++++ .github/workflows/iso.yml | 33 ++------- 3 files changed, 109 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/_build-iso.yml diff --git a/.github/actions/build-iso/action.yml b/.github/actions/build-iso/action.yml index 9529918a..1cc4954a 100644 --- a/.github/actions/build-iso/action.yml +++ b/.github/actions/build-iso/action.yml @@ -1,4 +1,5 @@ name: Build Image +description: "Build an ISO file for Atomic Fedora distributions with Flatpak dependencies" inputs: flatpak-manifest-list: diff --git a/.github/workflows/_build-iso.yml b/.github/workflows/_build-iso.yml new file mode 100644 index 00000000..506a2ba1 --- /dev/null +++ b/.github/workflows/_build-iso.yml @@ -0,0 +1,101 @@ +name: Build ISO + +on: + workflow_call: + inputs: + image-registry: + required: true + type: string + image-name: + required: true + type: string + image-tag: + required: true + type: string + flatpak-manifest-list: + required: true + type: string + installer-version: + required: true + type: number + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get Flatpak dependencies + id: flatpak-dependencies + env: + IMAGE_FULL: ${{ inputs.image-registry }}/${{ inputs.image-name }}:${{ inputs.image-tag }} + shell: bash + run: | + set -euox pipefail + + IMAGE="${IMAGE_FULL}" + + # Create temporary directory + TEMP_FLATPAK_INSTALL_DIR=$(mktemp -d -p /tmp flatpak-XXXXXX) + FLATPAK_REFS_DIR=$(mktemp -d -p /tmp flatpak-refs-XXXXXX) + cp "${{ inputs.flatpak-manifest-list }}" "${FLATPAK_REFS_DIR}/flatpaks.txt" + + # Read the list of Flatpak packages from the manifest + FLATPAK_REFS=() + while IFS= read -r line; do + FLATPAK_REFS+=("$line") + done < "${{ inputs.flatpak-manifest-list }}" + + # Generate installation script + cat < "${TEMP_FLATPAK_INSTALL_DIR}/install-flatpaks.sh" + mkdir -p /flatpak/flatpak /flatpak/triggers + mkdir /var/tmp + chmod -R 1777 /var/tmp + flatpak config --system --set languages "*" + flatpak remote-add --system flathub https://flathub.org/repo/flathub.flatpakrepo + flatpak install --system -y flathub ${FLATPAK_REFS[@]} + ostree refs --repo=\${FLATPAK_SYSTEM_DIR}/repo | grep '^deploy/' | grep -v 'org\.freedesktop\.Platform\.openh264' | sed 's/^deploy\///g' > /output/flatpaks-with-deps + EOF + docker run --rm --privileged \ + --entrypoint /bin/bash \ + -e FLATPAK_SYSTEM_DIR=/flatpak/flatpak \ + -e FLATPAK_TRIGGERS_DIR=/flatpak/triggers \ + -v ${FLATPAK_REFS_DIR}:/output \ + -v ${TEMP_FLATPAK_INSTALL_DIR}:/temp_flatpak_install_dir \ + ${IMAGE} /temp_flatpak_install_dir/install-flatpaks.sh + docker rmi ${IMAGE} + cat ${FLATPAK_REFS_DIR}/flatpaks-with-deps + wc -l ${FLATPAK_REFS_DIR}/flatpaks-with-deps + + echo "FLATPAK_REFS_DIR:${FLATPAK_REFS_DIR}" >> $GITHUB_OUTPUT + + - name: Build ISO + uses: jasonn3/build-container-installer@v1.2.2 + id: build-iso + with: + arch: x86_64 + image_name: ${{ inputs.image-name }} + image_repo: ${{ inputs.image-registry }} + image_tag: ${{ inputs.image-tag }} + variant: Kinoite + version: ${{ inputs.installer-version }} + secure_boot_key_url: "https://github.com/rsturla/akmods/raw/main/_certs/public_key.der" + enrollment_password: "password" + iso_name: "${{ inputs.image-name }}-${{ inputs.image-tag }}.iso" + enable_cache_dnf: false + enable_cache_skopeo: false + flatpak_remote_refs_dir: ${{ steps.flatpak-dependencies.outputs.FLATPAK_REFS_DIR }} + enable_flatpak_dependencies: false + + - name: Upload ISO to GitHub + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.build.outputs.iso-name }}-abc + path: | + ${{ steps.build-iso.outputs.iso_path }} + ${{ steps.build-iso.outputs.iso_path }}-CHECKSUM + if-no-files-found: error + retention-days: 5 + compression-level: 0 + overwrite: true diff --git a/.github/workflows/iso.yml b/.github/workflows/iso.yml index 2bc6d3be..bbe4dbf5 100644 --- a/.github/workflows/iso.yml +++ b/.github/workflows/iso.yml @@ -7,29 +7,10 @@ on: jobs: build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Build ISO - uses: ./.github/actions/build-iso - id: build - with: - flatpak-manifest-list: ./flatpaks.txt - installer-version: 40 - image-registry: ghcr.io/rsturla/eternal-linux/main - image-name: silverblue - image-tag: 40 - - - name: Upload ISO to GitHub - uses: actions/upload-artifact@v4 - with: - name: ${{ steps.build.outputs.iso-name }}-abc - path: | - ${{ steps.build.outputs.iso-file }} - ${{ steps.build.outputs.checksum-file }} - if-no-files-found: error - retention-days: 5 - compression-level: 0 - overwrite: true + uses: ./.github/workflows/_build-iso.yml + with: + image-name: silverblue + image-registry: ghcr.io/rsturla/eternal-linux/main + image-tag: 40 + flatpak-manifest-list: ./flatpaks.txt + installer-version: 40