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