-
Notifications
You must be signed in to change notification settings - Fork 6
204 lines (160 loc) · 7.55 KB
/
build-ipxe-images.yml
File metadata and controls
204 lines (160 loc) · 7.55 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
---
name: Build iPXE Images
"on":
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Run quarterly on the 1st day of Jan/Apr/Jul/Oct at 00:00 UTC
schedule:
- cron: '0 0 1 1,4,7,10 *'
jobs:
build-image:
runs-on: ubuntu-22.04
# Permission needed to create a release and upload assets
permissions:
contents: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install System Dependencies
run: |
echo "Installing system dependencies for iPXE build..."
sudo apt-get update
sudo apt-get install -y \
gcc \
make \
perl \
git \
libguestfs-tools
echo "System dependencies installed"
- name: Fix Kernel Permissions for libguestfs
run: |
echo "Setting kernel file permissions for libguestfs..."
sudo chmod -R a+rX /boot
echo "Kernel permissions updated"
- name: Build iPXE Images
run: |
echo "Building iPXE images using ipxe/Makefile..."
cd ipxe
make
echo "iPXE images built successfully"
ls -lh efi.img ipxe-boot-usb.raw
cd ..
- name: Create Release Tag and Rename Images
id: release_tag
run: |
# Generate timestamp-based tag
RELEASE_TAG="build-$(date +%Y%m%d-%H%M%S)"
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
echo "Release tag: $RELEASE_TAG"
# Rename images to include the release tag
TAGGED_EFI_IMAGE="ipxe-efi-${RELEASE_TAG}.img"
TAGGED_BIOS_IMAGE="ipxe-bios-${RELEASE_TAG}.img"
cp ipxe/efi.img ${TAGGED_EFI_IMAGE}
cp ipxe/ipxe-boot-usb.raw ${TAGGED_BIOS_IMAGE}
echo "tagged_efi_image=$TAGGED_EFI_IMAGE" >> $GITHUB_OUTPUT
echo "tagged_bios_image=$TAGGED_BIOS_IMAGE" >> $GITHUB_OUTPUT
echo "Images renamed:"
ls -lh ${TAGGED_EFI_IMAGE} ${TAGGED_BIOS_IMAGE}
# yamllint disable rule:line-length
- name: Create Versioned GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_tag.outputs.release_tag }}
name: "iPXE Images ${{ steps.release_tag.outputs.release_tag }}"
body: |
iPXE boot images built by GitHub Actions.
## Images Included
- **ipxe-efi-${{ steps.release_tag.outputs.release_tag }}.img** - UEFI boot image
- **ipxe-bios-${{ steps.release_tag.outputs.release_tag }}.img** - BIOS boot image (USB)
- **Build type**: ${{ github.event_name == 'schedule' && 'Scheduled (quarterly)' || 'Manual' }}
## Usage
These images are used for network booting OpenShift nodes in HotStack scenarios.
### Download
```bash
# Download UEFI boot image
curl -L -O https://github.com/${{ github.repository }}/releases/download/${{ steps.release_tag.outputs.release_tag }}/ipxe-efi-${{ steps.release_tag.outputs.release_tag }}.img
# Download BIOS boot image
curl -L -O https://github.com/${{ github.repository }}/releases/download/${{ steps.release_tag.outputs.release_tag }}/ipxe-bios-${{ steps.release_tag.outputs.release_tag }}.img
```
### Upload to Glance
See [iPXE README](https://github.com/${{ github.repository }}/blob/main/ipxe/README.md) for detailed upload instructions.
files: |
${{ steps.release_tag.outputs.tagged_efi_image }}
${{ steps.release_tag.outputs.tagged_bios_image }}
# yamllint enable rule:line-length
- name: Update 'latest-ipxe' Release Tag
uses: softprops/action-gh-release@v2
with:
tag_name: latest-ipxe
name: "iPXE Images (Latest)"
prerelease: true
body: |
This is the latest iPXE images build. This release is automatically updated.
**Latest Build**: ${{ steps.release_tag.outputs.release_tag }}
## Download
Use the static URLs for the latest build:
```bash
# Download UEFI boot image
curl -L -O https://github.com/${{ github.repository }}/releases/download/latest-ipxe/ipxe-efi-latest.img
# Download BIOS boot image
curl -L -O https://github.com/${{ github.repository }}/releases/download/latest-ipxe/ipxe-bios-latest.img
```
## Upload to Glance
Upload the BIOS boot image for OCP nodes:
```bash
openstack image create --disk-format=raw --file ipxe-bios-latest.img ipxe-boot-usb \
--property os_shutdown_timeout=5 \
--public
```
Upload the UEFI rescue image:
```bash
openstack image create --disk-format=raw --file ipxe-efi-latest.img ipxe-rescue-uefi \
--property os_shutdown_timeout=5 \
--property hw_firmware_type=uefi \
--property hw_machine_type=q35 \
--public
```
Upload the BIOS rescue image:
```bash
openstack image create --disk-format=raw --file ipxe-bios-latest.img ipxe-rescue-bios \
--property os_shutdown_timeout=5 \
--public
```
For detailed documentation, see the [iPXE README](https://github.com/${{ github.repository }}/blob/main/ipxe/README.md).
files: |
${{ steps.release_tag.outputs.tagged_efi_image }}
${{ steps.release_tag.outputs.tagged_bios_image }}
- name: Upload Images with Static Filenames to Latest Release
run: |
echo "Creating static filename copies for easy downloading..."
# Copy the images with static names
cp ${{ steps.release_tag.outputs.tagged_efi_image }} ipxe-efi-latest.img
cp ${{ steps.release_tag.outputs.tagged_bios_image }} ipxe-bios-latest.img
echo "Uploading to latest-ipxe release with static filenames..."
# Upload to latest-ipxe release, replacing any existing files with the same names
gh release upload latest-ipxe ipxe-efi-latest.img --clobber --repo ${{ github.repository }}
gh release upload latest-ipxe ipxe-bios-latest.img --clobber --repo ${{ github.repository }}
echo "Static URLs available at:"
echo "https://github.com/${{ github.repository }}/releases/download/latest-ipxe/ipxe-efi-latest.img"
echo "https://github.com/${{ github.repository }}/releases/download/latest-ipxe/ipxe-bios-latest.img"
env:
GH_TOKEN: ${{ github.token }}
- name: Cleanup Old Releases (Keep Last 4)
run: |
echo "Cleaning up old builds, keeping last 4..."
# Get all releases with 'build-' prefix, sort by creation date (newest first)
# Skip the first 4 (keep them), delete the rest
OLD_RELEASES=$(gh release list --limit 100 --json tagName,createdAt --repo ${{ github.repository }} \
| jq -r '.[] | select(.tagName | startswith("build-")) | .tagName' \
| sort -r \
| tail -n +5)
if [ -n "$OLD_RELEASES" ]; then
echo "Deleting old releases:"
echo "$OLD_RELEASES"
echo "$OLD_RELEASES" | xargs -I {} gh release delete {} --yes --cleanup-tag --repo ${{ github.repository }}
echo "Cleanup complete"
else
echo "No old releases to delete (fewer than 5 total)"
fi
env:
GH_TOKEN: ${{ github.token }}