azure-podvm-image-build #39
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: azure-podvm-image-build | |
on: | |
workflow_call: | |
inputs: | |
image-version: | |
type: string | |
required: true | |
outputs: | |
image-id: | |
description: "The PodVM image id" | |
value: ${{ jobs.build-podvm-image.outputs.image-id }} | |
workflow_dispatch: | |
inputs: | |
image-version: | |
type: string | |
description: x.y.z | |
git-ref: | |
type: string | |
default: 'main' | |
description: tag, branch, sha | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
AZURE_PODVM_IMAGE_DEF_NAME: "${{ vars.AZURE_PODVM_IMAGE_DEF_NAME }}" | |
AZURE_PODVM_IMAGE_VERSION: "${{ inputs.image-version }}" | |
PODVM_IMAGE_NAME: "peerpod-image-${{ github.run_id }}-${{ github.run_attempt }}" | |
UPLOSI_VERSION: "0.3.0" | |
UPLOSI_SHA256: "687bcab7398ab0fda65a3809492e8cd4d6a25aad1573927be5ec75ac1c4cbc35" | |
IMAGE_ID: "/CommunityGalleries/${{ vars.AZURE_COMMUNITY_GALLERY_NAME }}/Images/${{ vars.AZURE_PODVM_IMAGE_DEF_NAME }}/Versions/${{ inputs.image-version }}" | |
jobs: | |
build-podvm-image: | |
runs-on: ubuntu-22.04 | |
defaults: | |
run: | |
working-directory: cloud-api-adaptor/src/cloud-api-adaptor/podvm-mkosi | |
outputs: | |
image-id: "${{ steps.upload-image.outputs.image-id }}" | |
steps: | |
- name: Clone cloud-api-adaptor repository | |
uses: actions/checkout@v4 | |
with: | |
path: cloud-api-adaptor | |
ref: "${{ inputs.git-ref || 'main' }}" | |
- uses: cachix/install-nix-action@v30 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
- name: Install uplosi | |
run: | | |
wget "https://github.com/edgelesssys/uplosi/releases/download/v${UPLOSI_VERSION}/uplosi_${UPLOSI_VERSION}_linux_amd64.tar.gz" | |
sha256sum -c <(echo "$UPLOSI_SHA256" "uplosi_${UPLOSI_VERSION}_linux_amd64.tar.gz") | |
tar xzf uplosi_0.3.0_linux_amd64.tar.gz uplosi | |
sudo mv uplosi /usr/local/bin | |
- name: Build binaries | |
env: | |
TEE_PLATFORM: az-cvm-vtpm | |
VERIFY_PROVENANCE: yes | |
run: | | |
make fedora-binaries-builder | |
make binaries | |
- name: Install build dependencies | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y qemu-utils | |
- name: Build image | |
run: make image | |
- uses: azure/login@v2 | |
name: 'Az CLI login' | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
- name: upload image | |
id: upload-image | |
run: | | |
SHARING_NAME_PREFIX="$(echo ${{ vars.AZURE_COMMUNITY_GALLERY_NAME }} | cut -d'-' -f1)" | |
cat <<EOF> uplosi.conf | |
[base] | |
imageVersion = "$AZURE_PODVM_IMAGE_VERSION" | |
name = "$AZURE_PODVM_IMAGE_DEF_NAME" | |
[base.azure] | |
subscriptionID = "${{ secrets.AZURE_SUBSCRIPTION_ID }}" | |
location = "eastus" | |
resourceGroup = "${{ secrets.AZURE_RESOURCE_GROUP }}" | |
sharedImageGallery = "${{ secrets.AZURE_PODVM_GALLERY_NAME }}" | |
sharingNamePrefix = "$SHARING_NAME_PREFIX" | |
[variant.default] | |
provider = "azure" | |
[variant.default.azure] | |
replicationRegions = ["eastus","eastus2","westeurope","northeurope"] | |
EOF | |
uplosi upload build/system.raw | |
echo "successfully built $IMAGE_ID" | |
echo "image-id=${IMAGE_ID}" >> "$GITHUB_OUTPUT" |