Skip to content

Publish Gardenlinux Images with new OCI Spec #7

Publish Gardenlinux Images with new OCI Spec

Publish Gardenlinux Images with new OCI Spec #7

name: Publish GardenLinux New OCI Image
on:
pull_request:
workflow_dispatch:
inputs:
version:
description: "Specify the GardenLinux version to process (e.g., 1877.0)"
required: true
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Set Version
run: echo "VERSION=1877.0" >> $GITHUB_ENV
- name: Checkout Repository
uses: actions/checkout@v2
- name: Install Dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y jq curl git make
- name: Setup ORAS
uses: oras-project/setup-oras@v1
- name: Fetch OCI Index Manifest
id: fetch-manifest
run: |
VERSION=${{ github.event.inputs.version }}
INDEX_MANIFEST=$(oras manifest fetch ghcr.io/gardenlinux/gardenlinux:$VERSION | jq)
echo "$INDEX_MANIFEST" > index-manifest.json
echo "INDEX_MANIFEST=$INDEX_MANIFEST" >> $GITHUB_ENV
- name: Extract Metal PXE Layers
id: extract-layers
run: |
jq -c '.manifests[] | select(.annotations.cname | startswith("metal_pxe"))' index-manifest.json > metal-pxe-layers.json
echo "Extracted Metal PXE Layers:"
cat metal-pxe-layers.json
- name: Download and Extract Binaries
run: |
mkdir -p binaries/amd64 binaries/arm64
for layer in $(jq -c '.[]' metal-pxe-layers.json); do
ARCH=$(echo $layer | jq -r '.platform.architecture')
DIGEST=$(echo $layer | jq -r '.digest')
MANIFEST=$(oras manifest fetch ghcr.io/gardenlinux/gardenlinux@$DIGEST | jq)
echo "$MANIFEST" > manifest-$ARCH.json
for binary in initrd vmlinuz root.squashfs; do
BINARY_DIGEST=$(echo $MANIFEST | jq -r ".layers[] | select(.annotations.\"org.opencontainers.image.title\" == \"$binary\").digest")
curl -L -o binaries/$ARCH/$binary ghcr.io/v2/gardenlinux/gardenlinux/blobs/$BINARY_DIGEST
done
done
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Authenticate with GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Authenticating with GitHub..."
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
- name: Clone Ironcore Image Repository
run: |
git clone https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/ironcore-dev/ironcore-image.git
cd ironcore-image
make build
- name: Build New OCI Image
run: |
cd ironcore-image
./bin/ironcore-image build \
--tag ghcr.io/ironcore-dev/os-images/test-image:${{ github.event.inputs.version }} \
--config arch=amd64,squashfs=../binaries/amd64/squashfs,initramfs=../binaries/amd64/initrd,kernel=../binaries/amd64/vmlinuz \
--config arch=arm64,squashfs=../binaries/arm64/squashfs,initramfs=../binaries/arm64/initrd,kernel=../binaries/arm64/vmlinuz
- name: Push New OCI Image
run: |
cd ironcore-image
./ironcore-image push ghcr.io/ironcore-dev/os-images/test-image:${{ github.event.inputs.version }} --push-sub-manifests