Skip to content

Commit 7ecdff1

Browse files
committed
Add automated image workflows with retention
- Scheduled builds: weekly (controller), quarterly (blank, iPXE) - Timestamp-only versions: build-YYYYMMDD-HHMMSS - Auto-cleanup: keep last 4 releases Fix iPXE workflow kernel permissions for libguestfs Add kernel permission fix step to allow libguestfs supermin to access kernel files in GitHub Actions runners. Assisted-By: Claude (claude-4.5-sonnet) Signed-off-by: Harald Jensås <hjensas@redhat.com>
1 parent 32941d0 commit 7ecdff1

File tree

3 files changed

+98
-15
lines changed

3 files changed

+98
-15
lines changed

.github/workflows/build-blank-image.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ name: Build Blank Image
44
"on":
55
# Allows you to run this workflow manually from the Actions tab
66
workflow_dispatch:
7-
inputs:
8-
release_tag:
9-
description: 'Release tag (e.g., v1.0.0)'
10-
required: true
7+
8+
# Run quarterly on the 1st day of Jan/Apr/Jul/Oct at 00:00 UTC
9+
schedule:
10+
- cron: '0 0 1 1,4,7,10 *'
1111

1212
jobs:
1313
build-image:
@@ -45,7 +45,8 @@ jobs:
4545
- name: 4. Rename Image with Release Tag
4646
id: release_tag
4747
run: |
48-
RELEASE_TAG="${{ inputs.release_tag }}"
48+
# Generate timestamp-based tag
49+
RELEASE_TAG="build-$(date +%Y%m%d-%H%M%S)"
4950
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
5051
echo "Release tag: $RELEASE_TAG"
5152
@@ -70,6 +71,7 @@ jobs:
7071
7172
- **Format**: qcow2
7273
- **Size**: 1MB
74+
- **Build type**: ${{ github.event_name == 'schedule' && 'Scheduled (quarterly)' || 'Manual' }}
7375
- **Purpose**: Minimal blank disk image for virtual baremetal nodes with Redfish virtual BMC
7476
7577
## Usage
@@ -161,3 +163,25 @@ jobs:
161163
echo "https://github.com/${{ github.repository }}/releases/download/latest-blank/blank-image-latest.qcow2"
162164
env:
163165
GH_TOKEN: ${{ github.token }}
166+
167+
- name: 8. Cleanup Old Releases (Keep Last 4)
168+
run: |
169+
echo "Cleaning up old builds, keeping last 4..."
170+
171+
# Get all releases with 'build-' prefix, sort by creation date (newest first)
172+
# Skip the first 4 (keep them), delete the rest
173+
OLD_RELEASES=$(gh release list --limit 100 --json tagName,createdAt --repo ${{ github.repository }} \
174+
| jq -r '.[] | select(.tagName | startswith("build-")) | .tagName' \
175+
| sort -r \
176+
| tail -n +5)
177+
178+
if [ -n "$OLD_RELEASES" ]; then
179+
echo "Deleting old releases:"
180+
echo "$OLD_RELEASES"
181+
echo "$OLD_RELEASES" | xargs -I {} gh release delete {} --yes --cleanup-tag --repo ${{ github.repository }}
182+
echo "Cleanup complete"
183+
else
184+
echo "No old releases to delete (fewer than 5 total)"
185+
fi
186+
env:
187+
GH_TOKEN: ${{ github.token }}

.github/workflows/build-controller-image.yml

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ name: Build HotStack Controller Image
44
"on":
55
# Allows you to run this workflow manually from the Actions tab
66
workflow_dispatch:
7-
inputs:
8-
release_tag:
9-
description: 'Release tag (e.g., v1.0.0)'
10-
required: true
7+
8+
# Run weekly on Mondays at 00:00 UTC
9+
schedule:
10+
- cron: '0 0 * * 1'
1111

1212
jobs:
1313
build-image:
@@ -53,7 +53,13 @@ jobs:
5353
- name: 5. Rename Image with Release Tag
5454
id: release_tag
5555
run: |
56-
RELEASE_TAG="${{ inputs.release_tag }}"
56+
if [ "${{ github.event_name }}" == "schedule" ] || [ -z "${{ inputs.release_tag }}" ]; then
57+
# Scheduled run or no tag provided: generate timestamp-based tag
58+
RELEASE_TAG="build-$(date +%Y%m%d-%H%M%S)"
59+
else
60+
# Manual run with tag provided: use provided tag
61+
RELEASE_TAG="${{ inputs.release_tag }}"
62+
fi
5763
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
5864
echo "Release tag: $RELEASE_TAG"
5965
@@ -79,6 +85,7 @@ jobs:
7985
- **Base**: CentOS Stream 9
8086
- **Build Tool**: diskimage-builder (DIB)
8187
- **Format**: qcow2
88+
- **Build type**: ${{ github.event_name == 'schedule' && 'Scheduled (weekly)' || (inputs.release_tag == '' && 'Manual (auto-versioned)' || 'Manual (versioned)') }}
8289
- **Packages**: bash-completion, bind-utils, butane, dnsmasq, git,
8390
haproxy, httpd, httpd-tools, make, nfs-utils, nmstate, podman,
8491
tcpdump, tmux, vim-enhanced
@@ -162,3 +169,25 @@ jobs:
162169
echo "https://github.com/${{ github.repository }}/releases/download/latest-controller/controller-latest.qcow2"
163170
env:
164171
GH_TOKEN: ${{ github.token }}
172+
173+
- name: 9. Cleanup Old Releases (Keep Last 4)
174+
run: |
175+
echo "Cleaning up old builds, keeping last 4..."
176+
177+
# Get all releases with 'build-' prefix, sort by creation date (newest first)
178+
# Skip the first 4 (keep them), delete the rest
179+
OLD_RELEASES=$(gh release list --limit 100 --json tagName,createdAt --repo ${{ github.repository }} \
180+
| jq -r '.[] | select(.tagName | startswith("build-")) | .tagName' \
181+
| sort -r \
182+
| tail -n +5)
183+
184+
if [ -n "$OLD_RELEASES" ]; then
185+
echo "Deleting old releases:"
186+
echo "$OLD_RELEASES"
187+
echo "$OLD_RELEASES" | xargs -I {} gh release delete {} --yes --cleanup-tag --repo ${{ github.repository }}
188+
echo "Cleanup complete"
189+
else
190+
echo "No old releases to delete (fewer than 5 total)"
191+
fi
192+
env:
193+
GH_TOKEN: ${{ github.token }}

.github/workflows/build-ipxe-images.yml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ name: Build iPXE Images
44
"on":
55
# Allows you to run this workflow manually from the Actions tab
66
workflow_dispatch:
7-
inputs:
8-
release_tag:
9-
description: 'Release tag (e.g., v1.0.0)'
10-
required: true
7+
8+
# Run quarterly on the 1st day of Jan/Apr/Jul/Oct at 00:00 UTC
9+
schedule:
10+
- cron: '0 0 1 1,4,7,10 *'
1111

1212
jobs:
1313
build-image:
@@ -33,6 +33,12 @@ jobs:
3333
libguestfs-tools
3434
echo "System dependencies installed"
3535
36+
- name: Fix Kernel Permissions for libguestfs
37+
run: |
38+
echo "Setting kernel file permissions for libguestfs..."
39+
sudo chmod -R a+rX /boot
40+
echo "Kernel permissions updated"
41+
3642
- name: Build iPXE Images
3743
run: |
3844
echo "Building iPXE images using ipxe/Makefile..."
@@ -45,7 +51,8 @@ jobs:
4551
- name: Create Release Tag and Rename Images
4652
id: release_tag
4753
run: |
48-
RELEASE_TAG="${{ inputs.release_tag }}"
54+
# Generate timestamp-based tag
55+
RELEASE_TAG="build-$(date +%Y%m%d-%H%M%S)"
4956
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
5057
echo "Release tag: $RELEASE_TAG"
5158
@@ -75,6 +82,7 @@ jobs:
7582
7683
- **ipxe-efi-${{ steps.release_tag.outputs.release_tag }}.img** - UEFI boot image
7784
- **ipxe-bios-${{ steps.release_tag.outputs.release_tag }}.img** - BIOS boot image (USB)
85+
- **Build type**: ${{ github.event_name == 'schedule' && 'Scheduled (quarterly)' || 'Manual' }}
7886
7987
## Usage
8088
@@ -172,3 +180,25 @@ jobs:
172180
echo "https://github.com/${{ github.repository }}/releases/download/latest-ipxe/ipxe-bios-latest.img"
173181
env:
174182
GH_TOKEN: ${{ github.token }}
183+
184+
- name: Cleanup Old Releases (Keep Last 4)
185+
run: |
186+
echo "Cleaning up old builds, keeping last 4..."
187+
188+
# Get all releases with 'build-' prefix, sort by creation date (newest first)
189+
# Skip the first 4 (keep them), delete the rest
190+
OLD_RELEASES=$(gh release list --limit 100 --json tagName,createdAt --repo ${{ github.repository }} \
191+
| jq -r '.[] | select(.tagName | startswith("build-")) | .tagName' \
192+
| sort -r \
193+
| tail -n +5)
194+
195+
if [ -n "$OLD_RELEASES" ]; then
196+
echo "Deleting old releases:"
197+
echo "$OLD_RELEASES"
198+
echo "$OLD_RELEASES" | xargs -I {} gh release delete {} --yes --cleanup-tag --repo ${{ github.repository }}
199+
echo "Cleanup complete"
200+
else
201+
echo "No old releases to delete (fewer than 5 total)"
202+
fi
203+
env:
204+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)