Avoid an intermediate push of the Ironcore OCI image (#24) #44
This file contains hidden or 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: Publish GardenLinux Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| arch: [ "arm64", "amd64" ] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v2 | |
| - name: Install yq (YAML Processor) | |
| run: sudo snap install yq | |
| - name: Setup ORAS | |
| uses: oras-project/setup-oras@v1 | |
| - name: Read Config Files and Extract OS Version | |
| id: read-config | |
| run: | | |
| GARDENLINUX_KVM_ARTIFACT_URL=$(yq e .${{ matrix.arch }}.gardenlinux_kvm_artifact_url .github/os_image_artifacts.yml) | |
| GARDENLINUX_METAL_ARTIFACT_URL=$(yq e .${{ matrix.arch }}.gardenlinux_metal_artifact_url .github/os_image_artifacts.yml) | |
| echo "GARDENLINUX_KVM_ARTIFACT_URL=$GARDENLINUX_KVM_ARTIFACT_URL" >> $GITHUB_ENV | |
| echo "GARDENLINUX_METAL_ARTIFACT_URL=$GARDENLINUX_METAL_ARTIFACT_URL" >> $GITHUB_ENV | |
| OS_VERSION=$(echo $GARDENLINUX_KVM_ARTIFACT_URL | cut -d '/' -f 8) | |
| echo "OS_VERSION=$OS_VERSION" >> $GITHUB_ENV | |
| ARTIFACT_FOLDER=$(basename $GARDENLINUX_KVM_ARTIFACT_URL | sed 's/.tar.xz//') | |
| echo "ARTIFACT_FOLDER=$ARTIFACT_FOLDER" >> $GITHUB_ENV | |
| - name: Download and Extract Gardenlinux KVM Artifact | |
| run: | | |
| curl -L ${{ env.GARDENLINUX_KVM_ARTIFACT_URL }} -o gardenlinux.tar.xz | |
| tar -xf gardenlinux.tar.xz | |
| - name: Download and Extract Gardenlinux Metal Artifact | |
| run: | | |
| # Download the outer tarball | |
| curl -L ${{ env.GARDENLINUX_METAL_ARTIFACT_URL }} -o gardenlinux-metal.tar.xz | |
| tar -xf gardenlinux-metal.tar.xz | |
| # Extract the nested tarball to get the initrd, vmlinuz, and root.squashfs files | |
| NESTED_TARBALL=$(find . -name "*pxe.tar.gz") | |
| tar -xzf $NESTED_TARBALL | |
| - name: Create Config JSON | |
| run: | | |
| if [ "${{ matrix.arch }}" == "arm64" ]; then | |
| echo "{\"commandLine\": \"gl.url=/dev/disk/by-id/virtio-machineboot gl.live=1 gl.ovl=/:tmpfs console=tty0 console=ttyAMA0,115200 earlyprintk=ttyAMA0,115200 consoleblank=0 cgroup_enable=memory swapaccount=1 ignition.firstboot=1 ignition.platform.id=qemu\", \"os-release\": \"$OS_VERSION\", \"arch\": \"${{ matrix.arch }}\"}" > config.json | |
| fi | |
| if [ "${{ matrix.arch }}" == "amd64" ]; then | |
| echo "{\"commandLine\": \"gl.url=/dev/disk/by-id/virtio-machineboot gl.live=1 gl.ovl=/:tmpfs console=tty0 console=ttyS0,115200 earlyprintk=ttyS0,115200 consoleblank=0 cgroup_enable=memory swapaccount=1 ignition.firstboot=1 ignition.platform.id=qemu\", \"os-release\": \"$OS_VERSION\", \"arch\": \"${{ matrix.arch }}\"}" > config.json | |
| fi | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v1 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push Image with ORAS (Version Tag) | |
| run: | | |
| KVM_RAW_FILE=$(ls ${{ env.ARTIFACT_FOLDER }}/*.raw) | |
| METAL_SQUASHFS_FILE=root.squashfs | |
| METAL_INITRD_FILE=initrd | |
| METAL_VMLINUZ_FILE=vmlinuz | |
| oras push ghcr.io/ironcore-dev/os-images/gardenlinux-${{ matrix.arch }}:$OS_VERSION \ | |
| $KVM_RAW_FILE:application/vnd.ironcore.image.rootfs.v1alpha1.rootfs \ | |
| $METAL_SQUASHFS_FILE:application/vnd.ironcore.image.squashfs.v1alpha1.squashfs \ | |
| $METAL_INITRD_FILE:application/vnd.ironcore.image.initramfs.v1alpha1.initramfs \ | |
| $METAL_VMLINUZ_FILE:application/vnd.ironcore.image.vmlinuz.v1alpha1.vmlinuz \ | |
| --config config.json:application/vnd.ironcore.image.config.v1alpha1+json | |
| - name: Push Image with ORAS (Latest Tag) | |
| run: | | |
| oras tag ghcr.io/ironcore-dev/os-images/gardenlinux-${{ matrix.arch }}:$OS_VERSION latest |