From 9d2372f588939209ae2962c1ad2c94c530d40173 Mon Sep 17 00:00:00 2001 From: Lennart Jern Date: Wed, 24 Jan 2024 15:38:59 +0200 Subject: [PATCH] Add github action --- .github/workflows/osimages.yaml | 52 +++++++++++++++++++++++++++++++++ osimages/Makefile | 2 +- osimages/image-builder.patch | 31 ++++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/osimages.yaml create mode 100644 osimages/image-builder.patch diff --git a/.github/workflows/osimages.yaml b/.github/workflows/osimages.yaml new file mode 100644 index 0000000000..fec042357a --- /dev/null +++ b/.github/workflows/osimages.yaml @@ -0,0 +1,52 @@ +name: E2E node images + +on: + pull_request: + branches: [main] + paths-ignore: + - '**/*.md' + - 'docs/**' + - '.gitignore' + - 'hack/*.sh' + - 'LICENSE' + - 'SECURITY_CONTACTS' + - 'OWNERS' + +permissions: {} + +jobs: + build: + name: Build and upload node images + runs-on: ubuntu-latest + + permissions: + contents: read + + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + repository: kubernetes-sigs/image-builder + path: image-builder + ref: v0.1.22 + + - name: Patch image-builder Dockerfile with root user + run: git apply {{ github.workspace }}/cluster-api-provider-openstack/osimages/image-builder.patch + working-directory: "{{ github.workspace }}/image-builder" + + - name: Build image-builder image with root user + run: + working-directory: "{{ github.workspace }}/image-builder" + + - name: Build images + env: + OSIMAGE_BUILDER: gcr.io/scl-image-builder/cluster-node-image-builder-amd64:dev + run: make -C osimages -j2 ACCELERATOR=kvm \ + osimage-flatcar-1.27.2 \ + osimage-flatcar-1.28.2 \ + osimage-ubuntu-2204-1.28.2 \ + osimage-ubuntu-2204-1.27.2 + + - name: Upload images + run: make -C osimages osimage-upload diff --git a/osimages/Makefile b/osimages/Makefile index 27193a041b..94e0e7847c 100644 --- a/osimages/Makefile +++ b/osimages/Makefile @@ -67,7 +67,7 @@ osimage-%: FORCE .PHONY: FORCE FORCE: -.PHONY: osimage-upload: +.PHONY: osimage-upload osimage-upload: ls $(OSIMAGE_DIR) gsutil cp $(OSIMAGE_DIR)/* gs://$(STAGING_BUCKET)/test diff --git a/osimages/image-builder.patch b/osimages/image-builder.patch new file mode 100644 index 0000000000..d53ca1bd1b --- /dev/null +++ b/osimages/image-builder.patch @@ -0,0 +1,31 @@ +index 9514c03ae..372b8dfc2 100644 +--- a/images/capi/Dockerfile ++++ b/images/capi/Dockerfile +@@ -38,18 +38,15 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + ARG ARCH + ARG PASSED_IB_VERSION + +-USER imagebuilder +-WORKDIR /home/imagebuilder/ +- +-COPY --chown=imagebuilder:imagebuilder ansible ansible/ +-COPY --chown=imagebuilder:imagebuilder ansible.cfg ansible.cfg +-COPY --chown=imagebuilder:imagebuilder cloudinit cloudinit/ +-COPY --chown=imagebuilder:imagebuilder hack hack/ +-COPY --chown=imagebuilder:imagebuilder packer packer/ +-COPY --chown=imagebuilder:imagebuilder Makefile Makefile +-COPY --chown=imagebuilder:imagebuilder azure_targets.sh azure_targets.sh +- +-ENV PATH="/home/imagebuilder/.local/bin:${PATH}" ++COPY ansible ansible/ ++COPY ansible.cfg ansible.cfg ++COPY cloudinit cloudinit/ ++COPY hack hack/ ++COPY packer packer/ ++COPY Makefile Makefile ++COPY azure_targets.sh azure_targets.sh ++ ++ENV PATH="/root/.local/bin:${PATH}" + ENV PACKER_ARGS '' + ENV PACKER_VAR_FILES '' + ENV IB_VERSION "${PASSED_IB_VERSION}"