diff --git a/.github/workflows/build-ironic-images.yaml b/.github/workflows/build-ironic-images.yaml index 110d97ccf..23cf5890c 100644 --- a/.github/workflows/build-ironic-images.yaml +++ b/.github/workflows/build-ironic-images.yaml @@ -15,35 +15,74 @@ on: types: [checks_requested] jobs: - build-ironic-images: + discover: runs-on: ubuntu-latest + outputs: + yaml-files: ${{ steps.set-matrix.outputs.yaml-files }} + steps: + - name: Checkout repository + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4 + + - name: Find YAML files + id: set-matrix + run: | + yaml_files="[$(find . -maxdepth 1 -type f \( -name '*.yaml' -o -name '*.yml' \) -printf '"%f", ' | sed 's/, $//')]" + echo "yaml-files=${yaml_files}" >> $GITHUB_OUTPUT + working-directory: ironic-images + + build: + runs-on: ubuntu-latest + needs: discover defaults: run: - working-directory: ironic-images/ipa-debian-bookworm + working-directory: ironic-images + strategy: + matrix: + yaml-file: ${{ fromJson(needs.discover.outputs.yaml-files) }} + steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + + - name: Set up variables + run: | + echo "Processing YAML file: ${{ matrix.yaml-file }}" + imagename=$(grep -m 1 '^- imagename:' "${{ matrix.yaml-file }}" | awk '{print $3}') + echo "distro=${imagename%-*}" >> $GITHUB_ENV + echo "release=${imagename##*-}" >> $GITHUB_ENV + + - name: Setup python environment + uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5 id: setup-python with: python-version: '3.11' cache: 'pip' - - run: sudo apt update && sudo apt install -y debootstrap qemu-utils - - run: pip install -r requirements.txt - working-directory: ironic-images - - name: Build the IPA image - run: bash ipa-debian-bookworm.sh + + - name: Install Dependencies + run: sudo apt update && sudo apt install -y debootstrap qemu-utils squashfs-tools kpartx + + - name: Install python packages + run: pip install -r requirements.txt + + - name: Build Images + run: | + diskimage-builder ${{ matrix.yaml-file }} + mkdir -p upload + find . -maxdepth 1 -type f \( -name '*.qcow2' -o -name '*.kernel' -o -name '*.initramfs' \) -exec cp {} upload/ \; env: - ELEMENTS_PATH: ${{ env.pythonLocation }}/share/ironic-python-agent-builder/dib:${{ github.workspace }}/ironic-images/custom_elements - - name: Dynamically set timestamp environment variable - run: echo "TIMESTAMP=$(date +"%Y%m%d%H%M%S")" >> $GITHUB_ENV - - name: Publish IPA Release + DIB_RELEASE: ${{ env.release }} + ELEMENTS_PATH: "${{ env.distro == 'ipa-debian' && format('{0}/share/ironic-python-agent-builder/dib:{1}/ironic-images/custom_elements', env.pythonLocation, github.workspace) || ''}}" + + - name: Set timestamp environment variable + run: echo "TIMESTAMP=$(git show --no-patch --no-notes --pretty='%cd' --date=format:'%Y%m%d%H%M%S' ${{ github.sha }})" >> $GITHUB_ENV + + - name: Publish Release + id: create_release uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2 with: - name: undercloud-ironic-ipa - tag_name: undercloud-ironic-ipa-${{ env.TIMESTAMP }} + name: understack-images + tag_name: understack-images-${{ env.TIMESTAMP }} make_latest: true fail_on_unmatched_files: true - files: | - ironic-images/ipa-debian-bookworm/ipa-debian-bookworm.initramfs - ironic-images/ipa-debian-bookworm/ipa-debian-bookworm.kernel + files: ironic-images/upload/* if: ${{ github.ref == 'refs/heads/main' }} diff --git a/ironic-images/ipa-debian-bookworm/ipa-debian-bookworm.yaml b/ironic-images/ipa-debian-bookworm.yaml similarity index 100% rename from ironic-images/ipa-debian-bookworm/ipa-debian-bookworm.yaml rename to ironic-images/ipa-debian-bookworm.yaml diff --git a/ironic-images/ipa-debian-bookworm/README.md b/ironic-images/ipa-debian-bookworm/README.md deleted file mode 100644 index a841990d0..000000000 --- a/ironic-images/ipa-debian-bookworm/README.md +++ /dev/null @@ -1,4 +0,0 @@ -- Need to install package: debootstrap -- Create virtualenv -- pip install diskimage-builder ironic-python-agent-builder -- ./ipa-debian-bookworm.sh diff --git a/ironic-images/ipa-debian-bookworm/ipa-debian-bookworm.sh b/ironic-images/ipa-debian-bookworm/ipa-debian-bookworm.sh deleted file mode 100755 index 58ea9e8ef..000000000 --- a/ironic-images/ipa-debian-bookworm/ipa-debian-bookworm.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# elements path - need to include both the ironic-python-agent-builder DIB packages -# and our custom_elements packages -# export ELEMENTS_PATH=/path/to/venv/share/ironic-python-agent-builder/dib:/path/to/custom_elements - -# distro version -export DIB_RELEASE=bookworm - -diskimage-builder ipa-debian-bookworm.yaml diff --git a/ironic-images/ubuntu.yaml b/ironic-images/ubuntu.yaml new file mode 100644 index 000000000..cb7c2a6d6 --- /dev/null +++ b/ironic-images/ubuntu.yaml @@ -0,0 +1,8 @@ +- imagename: ubuntu-noble + elements: + - ubuntu + - grub2 + - block-device-efi + - baremetal + - bootloader + - package-installs