From 765959b5046802b56ff9947b59e4303188dabc46 Mon Sep 17 00:00:00 2001 From: Andreas Fritzler Date: Mon, 29 Jan 2024 13:31:35 +0100 Subject: [PATCH] Initial commit --- .github/os_image_artifacts.yml | 2 + .github/workflows/publish-gardenlinux.yml | 67 +++++++++++++++++++++++ .gitignore | 1 + 3 files changed, 70 insertions(+) create mode 100644 .github/os_image_artifacts.yml create mode 100644 .github/workflows/publish-gardenlinux.yml create mode 100644 .gitignore diff --git a/.github/os_image_artifacts.yml b/.github/os_image_artifacts.yml new file mode 100644 index 0000000..3dcf3de --- /dev/null +++ b/.github/os_image_artifacts.yml @@ -0,0 +1,2 @@ +gardenlinux_artifact_url: https://github.com/gardenlinux/gardenlinux/releases/download/1312.2/kvm-gardener_prod-amd64-1312.2-77c8471d.tar.xz +# You can add more OS specific URLs here later. diff --git a/.github/workflows/publish-gardenlinux.yml b/.github/workflows/publish-gardenlinux.yml new file mode 100644 index 0000000..3f601fa --- /dev/null +++ b/.github/workflows/publish-gardenlinux.yml @@ -0,0 +1,67 @@ +name: Publish GardenLinux Image + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Install yq (YAML Processor) + run: sudo snap install yq + + - name: Read Config File and Extract OS Version + id: read-config + run: | + GARDENLINUX_ARTIFACT_URL=$(yq e '.gardenlinux_artifact_url' .github/os_image_artifacts.yml) + echo "GARDENLINUX_ARTIFACT_URL=$GARDENLINUX_ARTIFACT_URL" >> $GITHUB_ENV + OS_VERSION=$(echo $GARDENLINUX_ARTIFACT_URL | cut -d '/' -f 8) + echo "OS_VERSION=$OS_VERSION" >> $GITHUB_ENV + ARTIFACT_FOLDER=$(basename $GARDENLINUX_ARTIFACT_URL | sed 's/.tar.xz//') + echo "ARTIFACT_FOLDER=$ARTIFACT_FOLDER" >> $GITHUB_ENV + + - name: Set up Go 1.21 + uses: actions/setup-go@v2 + with: + go-version: '1.21' + + - name: Install ORAS + run: | + go install github.com/oras-project/oras/cmd/oras@latest + echo "$HOME/go/bin" >> $GITHUB_PATH + + - name: Download and Extract Gardenlinux Artifact + run: | + curl -L ${{ env.GARDENLINUX_ARTIFACT_URL }} -o gardenlinux.tar.xz + tar -xf gardenlinux.tar.xz + + - name: Create Dummy Kernel and Initrd Files + run: | + dd if=/dev/zero of=dummy_kernel bs=1M count=1 + dd if=/dev/zero of=dummy_initrd bs=1M count=1 + + - name: Create Config JSON + run: | + echo "{\"commandLine\": \"\", \"os-release\": \"$OS_VERSION\"}" > config.json + + - 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 + run: | + RAW_FILE=$(ls ${{ env.ARTIFACT_FOLDER }}/*.raw) + oras push ghcr.io/ironcore-dev/os-images/gardenlinux:latest \ + $RAW_FILE:application/vnd.ironcore.image.rootfs.v1alpha1.rootfs \ + dummy_kernel:application/vnd.ironcore.image.vmlinuz.v1alpha1.vmlinuz \ + dummy_initrd:application/vnd.onmetal.image.initramfs.v1alpha1.initramfs \ + --config config.json:application/vnd.ironcore.image.config.v1alpha1+json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/