-
Notifications
You must be signed in to change notification settings - Fork 6
187 lines (155 loc) · 7.06 KB
/
build-blank-image.yml
File metadata and controls
187 lines (155 loc) · 7.06 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
---
name: Build Blank Image
"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: 1. Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: 2. Install System Dependencies
run: |
echo "Installing system dependencies for image building..."
sudo apt-get update
sudo apt-get install -y \
qemu-utils \
make
echo "System dependencies installed"
- name: 3. Build Blank Image Using Makefile
run: |
echo "Building blank image using images/Makefile..."
cd images
make blank BLANK_IMAGE_FORMAT=qcow2
echo "Blank image built successfully"
ls -lh blank-image.qcow2
qemu-img info blank-image.qcow2
cd ..
- name: 4. Rename Image with Release Tag
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 image to include the release tag
TAGGED_IMAGE="blank-image-${RELEASE_TAG}.qcow2"
cp images/blank-image.qcow2 ${TAGGED_IMAGE}
echo "tagged_image=$TAGGED_IMAGE" >> $GITHUB_OUTPUT
echo "Image renamed to: $TAGGED_IMAGE"
ls -lh ${TAGGED_IMAGE}
# yamllint disable rule:line-length
- name: 5. Create Versioned GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_tag.outputs.release_tag }}
name: "Blank Image ${{ steps.release_tag.outputs.release_tag }}"
body: |
HotStack Blank image built by GitHub Actions.
## Image Details
- **Format**: qcow2
- **Size**: 1MB
- **Build type**: ${{ github.event_name == 'schedule' && 'Scheduled (quarterly)' || 'Manual' }}
- **Purpose**: Minimal blank disk image for virtual baremetal nodes with Redfish virtual BMC
## Usage
```bash
# Download the image
curl -L -O https://github.com/${{ github.repository }}/releases/download/${{ steps.release_tag.outputs.release_tag }}/${{ steps.release_tag.outputs.tagged_image }}
# Upload to OpenStack Glance (qcow2 works for most deployments)
openstack image create sushy-tools-blank-image \
--disk-format qcow2 \
--container-format bare \
--property hw_firmware_type=uefi \
--property hw_machine_type=q35 \
--property os_shutdown_timeout=5 \
--file ${{ steps.release_tag.outputs.tagged_image }}
# If you need raw format (required for some Ceph RBD backends):
qemu-img convert -f qcow2 -O raw \
${{ steps.release_tag.outputs.tagged_image }} blank-image.raw
openstack image create sushy-tools-blank-image \
--disk-format raw \
--container-format bare \
--property hw_firmware_type=uefi \
--property hw_machine_type=q35 \
--property os_shutdown_timeout=5 \
--file blank-image.raw
```
files: ${{ steps.release_tag.outputs.tagged_image }}
# yamllint enable rule:line-length
- name: 6. Update 'latest-blank' Release Tag
uses: softprops/action-gh-release@v2
with:
tag_name: latest-blank
name: "Blank Image (Latest)"
prerelease: true
body: |
This is the latest Blank image build. This release is automatically updated.
**Latest Build**: ${{ steps.release_tag.outputs.release_tag }}
## Download
Use the static URL for the latest build:
```bash
curl -L -O https://github.com/${{ github.repository }}/releases/download/latest-blank/blank-image-latest.qcow2
```
Or download a specific version from the [releases page](https://github.com/${{ github.repository }}/releases)
to pin your setup to a known-good build.
## Usage
```bash
# Upload to OpenStack Glance (qcow2 works for most deployments)
openstack image create sushy-tools-blank-image \
--disk-format qcow2 \
--container-format bare \
--property hw_firmware_type=uefi \
--property hw_machine_type=q35 \
--property os_shutdown_timeout=5 \
--file blank-image-latest.qcow2
# If you need raw format (required for some Ceph RBD backends):
qemu-img convert -f qcow2 -O raw blank-image-latest.qcow2 blank-image.raw
openstack image create sushy-tools-blank-image \
--disk-format raw \
--container-format bare \
--property hw_firmware_type=uefi \
--property hw_machine_type=q35 \
--property os_shutdown_timeout=5 \
--file blank-image.raw
```
files: ${{ steps.release_tag.outputs.tagged_image }}
- name: 7. Upload Image with Static Filename to Latest Release
run: |
echo "Creating static filename copy for easy downloading..."
# Copy the image with a static name
cp ${{ steps.release_tag.outputs.tagged_image }} blank-image-latest.qcow2
echo "Uploading to latest-blank release with static filename..."
# Upload to latest-blank release, replacing any existing file with the same name
gh release upload latest-blank blank-image-latest.qcow2 --clobber --repo ${{ github.repository }}
echo "Static URL available at:"
echo "https://github.com/${{ github.repository }}/releases/download/latest-blank/blank-image-latest.qcow2"
env:
GH_TOKEN: ${{ github.token }}
- name: 8. 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 }}