Skip to content
Merged
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
75 changes: 57 additions & 18 deletions .github/workflows/build-ironic-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we're doing a matrix I think we'll have to split up the release into its own step. Because this will cause two release tags to be published. So I think each build will need to use the https://github.com/actions/upload-artifact to upload the built bits. Then the create release step will need to download those artifacts and make the release from that so that there's one release with all the files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used timestamp of the commit sha so that it would be one release. The previous version generated a timestamp when the job run so with two jobs, you get two timestamp and 2 releases. The image that I added to the PR shows the one release and the three built files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the GitHub Actions matrix runner will run each one separately to completion. You are creating the release in the matrix so it'll make 2 releases on each run instead of one combined release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/argoproj/argo-workflows/blob/main/.github/workflows/release.yaml that's an example of a matrix then coming back together to one 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' }}
4 changes: 0 additions & 4 deletions ironic-images/ipa-debian-bookworm/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions ironic-images/ipa-debian-bookworm/ipa-debian-bookworm.sh

This file was deleted.

8 changes: 8 additions & 0 deletions ironic-images/ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- imagename: ubuntu-noble
elements:
- ubuntu
- grub2
- block-device-efi
- baremetal
- bootloader
- package-installs