diff mbox series

[ovs-dev,v2,7/9] ci: Add automation for building the containers

Message ID 20230315062936.1101744-8-amusil@redhat.com
State Accepted
Headers show
Series Use containers on CI | expand

Commit Message

Ales Musil March 15, 2023, 6:29 a.m. UTC
In order to use the containers in CI build
the containers regularly so everything is up
to date. Build both Dockerfiles (Fedora, Ubuntu)
that are currently available.

Signed-off-by: Ales Musil <amusil@redhat.com>
---
 .github/workflows/containers.yml | 55 ++++++++++++++++++++++++++++++++
 Makefile.am                      |  1 +
 2 files changed, 56 insertions(+)
 create mode 100644 .github/workflows/containers.yml
diff mbox series

Patch

diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml
new file mode 100644
index 000000000..57e815ed8
--- /dev/null
+++ b/.github/workflows/containers.yml
@@ -0,0 +1,55 @@ 
+name: Containers
+on:
+  # Be able to run the job manually when needed
+  workflow_dispatch:
+  # Build every week on Monday 00:00
+  schedule:
+    - cron:  '0 0 * * 1'
+
+env:
+  IMAGE_REGISTRY: ghcr.io
+  IMAGE_NAMESPACE: ovn-org
+  IMAGE_NAME: ovn-tests
+  CONTAINERS_PATH: ./utilities/containers
+  DEPENDENCIES: podman
+
+jobs:
+  container:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        distro: [ fedora, ubuntu ]
+    steps:
+      - uses: actions/checkout@v3
+
+      - name: Update APT cache
+        run: sudo apt update
+
+      - name: Install dependencies
+        run: sudo apt install -y ${{ env.DEPENDENCIES }}
+
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v2
+
+      - name: Build container images
+        id: build-image
+        uses: redhat-actions/buildah-build@v2
+        with:
+          image: ${{ env.IMAGE_NAME }}
+          archs: amd64, arm64
+          tags: ${{ matrix.distro }}
+          build-args: CONTAINERS_PATH=${{ env.CONTAINERS_PATH }}
+          dockerfiles: ${{ env.CONTAINERS_PATH }}/${{ matrix.distro }}/Dockerfile
+
+      - name: Push to ghcr.io
+        id: push-to-registry
+        uses: redhat-actions/push-to-registry@v2
+        with:
+          image: ${{ steps.build-image.outputs.image }}
+          tags: ${{ steps.build-image.outputs.tags }}
+          registry: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAMESPACE }}
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Print image url
+        run: echo "Image pushed to ${{ steps.push-to-registry.outputs.registry-paths }}"
diff --git a/Makefile.am b/Makefile.am
index 8c60d4a71..4be2d48d4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -93,6 +93,7 @@  EXTRA_DIST = \
 	.ci/ovn-kubernetes/Dockerfile \
 	.ci/ovn-kubernetes/prepare.sh \
 	.ci/ovn-kubernetes/custom.patch \
+	.github/workflows/containers.yml \
 	.github/workflows/test.yml \
 	.github/workflows/ovn-kubernetes.yml \
 	boot.sh \