From e481282fc3747624a7a23473ac181d6f67e5c142 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 21 Dec 2021 14:15:51 +0100 Subject: [PATCH 1/2] ci: build and push container images after merge The container images should get pushed to quay.io after a PR has been merged. This currently builds the container images for all the architectures that the golang base container and Docker Actions support. Signed-off-by: Niels de Vos --- .github/workflows/build-push.yaml | 68 +++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/build-push.yaml diff --git a/.github/workflows/build-push.yaml b/.github/workflows/build-push.yaml new file mode 100644 index 000000000..a5a57816f --- /dev/null +++ b/.github/workflows/build-push.yaml @@ -0,0 +1,68 @@ +--- +name: Publish container images in quay.io + +on: + push: + branches: + - main + +jobs: + push_controller: + name: Push controller container image to quay.io + if: github.repository == 'csi-addons/kubernetes-csi-addons' + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to quay.io + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + + - name: Build and push controller container image + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7 + push: true + tags: quay.io/csi-addons/k8s-controller:latest + + push_sidecar: + name: Push sidecar container image to quay.io + if: github.repository == 'csi-addons/kubernetes-csi-addons' + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to quay.io + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + + - name: Build and push sidecar container image + uses: docker/build-push-action@v2 + with: + context: . + file: build/Containerfile.sidecar + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7 + push: true + tags: quay.io/csi-addons/k8s-sidecar:latest From d1129b7281a42a7b906ce1678319f96cc7cac0e3 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 21 Dec 2021 15:55:28 +0100 Subject: [PATCH 2/2] ci: add GitHub Workflow for building container-images Test building container images, so that Mergify can require `build_controller` and `build_sidecar` as CI jobs. Signed-off-by: Niels de Vos --- .github/workflows/test-build.yaml | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/test-build.yaml diff --git a/.github/workflows/test-build.yaml b/.github/workflows/test-build.yaml new file mode 100644 index 000000000..de7f485c4 --- /dev/null +++ b/.github/workflows/test-build.yaml @@ -0,0 +1,52 @@ +--- +name: Test building container images + +on: + pull_request: + branches: + - "*" + +jobs: + build_controller: + name: Build controller container image + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build container container image + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7 + push: false + tags: quay.io/csi-addons/k8s-controller:latest + + build_sidecar: + name: Test sidecar container image + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build sidecar container image + uses: docker/build-push-action@v2 + with: + context: . + file: build/Containerfile.sidecar + platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/arm/v7 + push: false + tags: quay.io/csi-addons/k8s-sidecar:latest