Build Ubicloud Image #326
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Ubicloud Image | |
on: | |
workflow_dispatch: | |
inputs: | |
image_type: | |
description: Image Type | |
required: true | |
default: ubuntu-noble | |
type: choice | |
options: | |
- ubuntu-noble | |
- ubuntu-jammy | |
- debian-12 | |
- almalinux-9 | |
- almalinux-8 | |
image_arch: | |
description: Image Arch | |
required: true | |
default: x64 | |
type: choice | |
options: | |
- x64 | |
- arm64 | |
image_version: | |
description: Image Version | |
required: true | |
type: string | |
jobs: | |
upload: | |
runs-on: ubicloud-standard-16 | |
env: | |
MC_HOST_ubicloud: ${{ secrets.MINIO_CONNECTION_STRING }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Install MinIO client | |
run: | | |
curl https://dl.min.io/client/mc/release/linux-amd64/mc -o mc | |
sudo mv mc /usr/bin/mc | |
sudo chmod +x /usr/bin/mc | |
mc --version | |
- name: Set MinIO root certificates | |
run: | | |
mkdir -p ~/.mc/certs/CAs | |
cat <<EOT > ~/.mc/certs/CAs/ubicloud_images_blob_storage_certs.crt | |
${{ secrets.MINIO_ROOT_CERTIFICATES }} | |
EOT | |
- name: Set image details | |
id: set_image_details | |
run: | | |
case "${{ inputs.image_type }}" in | |
"ubuntu-noble") | |
image_format="img" | |
[[ "${{ inputs.image_arch }}" = "x64" ]] && arch="amd64" || arch="arm64" | |
download_url="https://cloud-images.ubuntu.com/releases/noble/release-${{ inputs.image_version }}/ubuntu-24.04-server-cloudimg-${arch}.img" | |
;; | |
"ubuntu-jammy") | |
image_format="img" | |
[[ "${{ inputs.image_arch }}" = "x64" ]] && arch="amd64" || arch="arm64" | |
download_url="https://cloud-images.ubuntu.com/releases/jammy/release-${{ inputs.image_version }}/ubuntu-22.04-server-cloudimg-${arch}.img" | |
;; | |
"debian-12") | |
image_format="raw" | |
[[ "${{ inputs.image_arch }}" = "x64" ]] && arch="amd64" || arch="arm64" | |
download_url="https://cloud.debian.org/images/cloud/bookworm/${{ inputs.image_version }}/debian-12-genericcloud-${arch}-${{ inputs.image_version }}.raw" | |
;; | |
"almalinux-8") | |
image_format="qcow2" | |
[[ "${{ inputs.image_arch }}" = "arm64" ]] && exit 1 | |
download_url="https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/AlmaLinux-8-GenericCloud-${{ inputs.image_version }}.x86_64.qcow2" | |
;; | |
"almalinux-9") | |
image_format="qcow2" | |
[[ "${{ inputs.image_arch }}" = "x64" ]] && arch="x86_64" || arch="aarch64" | |
download_url="https://repo.almalinux.org/almalinux/9/cloud/${arch}/images/AlmaLinux-9-GenericCloud-${{ inputs.image_version }}.${arch}.qcow2" | |
esac | |
echo "IMAGE_DOWNLOAD_URL=$download_url" >> $GITHUB_OUTPUT | |
echo "IMAGE_FILE_NAME=${{ inputs.image_type }}-${{ inputs.image_arch }}-${{ inputs.image_version }}.$image_format" >> $GITHUB_OUTPUT | |
- name: Download image from the source | |
run: | | |
curl -f -L10 -o "${{ steps.set_image_details.outputs.IMAGE_FILE_NAME }}" "${{ steps.set_image_details.outputs.IMAGE_DOWNLOAD_URL }}" | |
- name: Create MinIO bucket | |
run: mc mb --ignore-existing ubicloud/ubicloud-images | |
- name: Upload the image to MinIO with version | |
run: | | |
mc cp ./${{ steps.set_image_details.outputs.IMAGE_FILE_NAME }} ubicloud/ubicloud-images/${{ steps.set_image_details.outputs.IMAGE_FILE_NAME }} | |
- name: Calculate SHA256 checksum | |
run: | | |
sha256sum ${{ steps.set_image_details.outputs.IMAGE_FILE_NAME }} > ${{ steps.set_image_details.outputs.IMAGE_FILE_NAME }}.sha256 | |
cat ${{ steps.set_image_details.outputs.IMAGE_FILE_NAME }}.sha256 | |
mc cp ./${{ steps.set_image_details.outputs.IMAGE_FILE_NAME }}.sha256 ubicloud/ubicloud-images/${{ steps.set_image_details.outputs.IMAGE_FILE_NAME }}.sha256 |