Skip to content

Commit d731958

Browse files
Merge pull request #157 from eduolivares/wntp-images
Add workflow to build custom WNTP image
2 parents 58829e9 + 89a4837 commit d731958

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Build Customized Image for WNTP
2+
3+
on:
4+
# Allows you to run this workflow manually from the Actions tab
5+
workflow_dispatch:
6+
inputs:
7+
release_tag:
8+
description: 'Release tag (e.g., v1.0.0)'
9+
required: true
10+
customize_args:
11+
description: 'Space-separated arguments for virt-customize'
12+
required: true
13+
default: >-
14+
--install tcpdump,nmap,python3,keepalived,iperf3
15+
--root-password password:12345678
16+
--selinux-relabel
17+
18+
jobs:
19+
build-image:
20+
# TODO(eduolivares): the virt-customize command fails with ubuntu-24.04/ubuntu-latest
21+
runs-on: ubuntu-22.04
22+
23+
# Permission needed to create a release and upload assets
24+
permissions:
25+
contents: write
26+
27+
env:
28+
# Base image URL
29+
BASE_IMAGE_URL: https://dl.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2
30+
BASE_IMAGE_FILE: Rocky-9-GenericCloud-Base.latest.x86_64.qcow2
31+
32+
# Define our custom output image name
33+
CUSTOM_IMAGE_FILE: wntp-custom-${{ inputs.release_tag }}.qcow2
34+
35+
steps:
36+
- name: 1. Install Dependencies
37+
run: |
38+
echo "Installing libguestfs-tools (for virt-customize) and wget"
39+
sudo apt-get update
40+
sudo apt-get install -y libguestfs-tools wget
41+
42+
- name: 2. Download Base Rocky Linux Image
43+
run: |
44+
echo "Downloading from ${{ env.BASE_IMAGE_URL }}"
45+
wget -O ${{ env.BASE_IMAGE_FILE }} ${{ env.BASE_IMAGE_URL }}
46+
47+
- name: 3. Customize Image
48+
run: |
49+
# Copy the downloaded image and give it our custom name
50+
sudo cp ${{ env.BASE_IMAGE_FILE }} /tmp/${{ env.CUSTOM_IMAGE_FILE }}
51+
52+
echo "Running virt-customize with args: ${{ inputs.customize_args }}"
53+
54+
# virt-customize modifies the image file in-place
55+
sudo LIBGUESTFS_BACKEND=direct virt-customize -a /tmp/${{ env.CUSTOM_IMAGE_FILE }} ${{ inputs.customize_args }}
56+
57+
# Move the customized image back to the working directory
58+
sudo mv /tmp/${{ env.CUSTOM_IMAGE_FILE }} ${{ env.CUSTOM_IMAGE_FILE }}
59+
60+
# Change ownership back to the runner user so the file can be read
61+
echo "Resetting file ownership..."
62+
sudo chown $(whoami):$(whoami) ${{ env.CUSTOM_IMAGE_FILE }}
63+
64+
- name: 4. Create GitHub Release and Upload Artifact
65+
uses: softprops/action-gh-release@v2
66+
with:
67+
# This is the tag you provided as input
68+
tag_name: ${{ inputs.release_tag }}
69+
70+
# Title for the release
71+
name: "Custom WNTP ${{ inputs.release_tag }} Image"
72+
73+
# Release description
74+
body: |
75+
Customized Rocky Linux 9 image for whitebox-neutron-tempest-plugin (WNTP) tests.
76+
77+
**Base Image:** Rocky-9-GenericCloud-Base.latest.x86_64.qcow2
78+
79+
**Customizations:**
80+
```
81+
${{ inputs.customize_args }}
82+
```
83+
84+
# The file(s) to upload
85+
files: ${{ env.CUSTOM_IMAGE_FILE }}

0 commit comments

Comments
 (0)