Skip to content

Commit

Permalink
Build reusable workflow rather than action
Browse files Browse the repository at this point in the history
  • Loading branch information
p5 committed Aug 9, 2024
1 parent 9f6b46a commit 4b84da4
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/actions/build-iso/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Build Image
description: "Build an ISO file for Atomic Fedora distributions with Flatpak dependencies"

inputs:
flatpak-manifest-list:
Expand Down
101 changes: 101 additions & 0 deletions .github/workflows/_build-iso.yml
Original file line number Diff line number Diff line change
@@ -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 <<EOF > "${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/[email protected]
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
33 changes: 7 additions & 26 deletions .github/workflows/iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4b84da4

Please sign in to comment.