Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(build): Add a CI workflow to build and push multiubuntu image whenever a change detected #1878

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/ci-build-and-push-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: ci-build-and-push-ubuntu

on:
push:
branches:
- main

jobs:
build:
if: github.repository == 'kubearmor/kubearmor'
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
submodules: true

- name: Set up QEMU for multi-architecture builds
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64/v8

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_AUTHTOK }}

- name: Build and push multi-architecture image
uses: docker/build-push-action@v6
with:
context: examples/multiubuntu/build
file: examples/multiubuntu/build/Dockerfile
push: true
tags: kubearmor/ubuntu-w-utils:latest
platforms: linux/amd64,linux/arm64/v8

- name: Logout from Docker Hub
run: docker logout
13 changes: 13 additions & 0 deletions .github/workflows/ci-test-ginkgo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- ".github/workflows/ci-test-ginkgo.yml"
- "pkg/KubeArmorOperator/**"
- "deployments/helm/**"
- "examples/multiubuntu/build/**"
pull_request:
branches: [main]
paths:
Expand All @@ -20,6 +21,7 @@ on:
- "examples/multiubuntu/build/**"
- "pkg/KubeArmorOperator/**"
- "deployments/helm/**"
- "examples/multiubuntu/build/**"

# Declare default permissions as read only.
permissions: read-all
Expand Down Expand Up @@ -75,6 +77,11 @@ jobs:
- name: Build KubeArmorController
if: steps.filter.outputs.controller == 'true'
run: make -C pkg/KubeArmorController/ docker-build TAG=latest

- name: Build multiubuntu image
run: |
cd examples/multiubuntu/build
docker build -t kubearmor/multiubuntu:latest .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the name to kubearmor/ubuntu-w-utils:latest


- name: deploy pre existing pod
run: |
Expand All @@ -84,6 +91,12 @@ jobs:

- name: Run KubeArmor
run: |
if [[ ${{ matrix.runtime }} == "containerd" ]]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why another if statement? Is there any problem for putting in the same if statement?

Copy link
Author

@sikehish sikehish Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why another if statement? Is there any problem for putting in the same if statement?

I thought it'd make it a bit more readable(as the kubearmor related images would be in a different block and the multiubuntu docker save block would be prominent enough. I'll make that change right away :)

docker save kubearmor/multiubuntu:latest | sudo k3s ctr images import -
else
docker save kubearmor/multiubuntu:latest | sudo podman load
sudo podman tag localhost/latest:latest docker.io/kubearmor/multiubuntu:latest
fi
if [[ ${{ matrix.runtime }} == "containerd" ]]; then
docker save kubearmor/kubearmor-test-init:latest | sudo k3s ctr images import -
docker save kubearmor/kubearmor-test:latest | sudo k3s ctr images import -
Expand Down