Skip to content

Commit

Permalink
feat(ci): Add build-adapters-image job
Browse files Browse the repository at this point in the history
Signed-off-by: Anurag Rajawat <[email protected]>
  • Loading branch information
anurag-rajawat committed Jan 29, 2024
1 parent 6e384dc commit ec36c2c
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 28 deletions.
46 changes: 19 additions & 27 deletions .github/workflows/latest-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,26 @@ on:

permissions: read-all

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release-nimbus-image:
if: github.repository == '5GSEC/nimbus'
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
name: Build and push nimbus image
uses: ./.github/workflows/release-image.yaml
with:
WORKING_DIRECTORY: .
secrets: inherit

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get tag
id: tag
run: |
if [ ${{ github.ref }} == "refs/heads/main" ]; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
fi
- name: Build and push nimbus image
run: make docker-buildx TAG=${{ steps.tag.outputs.tag }}
release-adapters-image:
if: github.repository == '5GSEC/nimbus'
strategy:
matrix:
adapters: [ "nimbus-kubearmor", "nimbus-netpol" ]
name: Build and push ${{ matrix.adapters }} adapter's image
uses: ./.github/workflows/release-image.yaml
with:
WORKING_DIRECTORY: ./pkg/adapter/${{ matrix.adapters }}
secrets: inherit
15 changes: 15 additions & 0 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,18 @@ jobs:

- name: Build image
run: make docker-build

build-adapters-image:
strategy:
matrix:
adapters: [ "nimbus-kubearmor", "nimbus-netpol" ]
name: Build ${{ matrix.adapters }} adapter's image
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Build image
working-directory: ./pkg/adapter/${{ matrix.adapters }}
run: make docker-build
46 changes: 46 additions & 0 deletions .github/workflows/release-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2023 Authors of Nimbus

name: release image
permissions: read-all

on:
workflow_call:
inputs:
WORKING_DIRECTORY:
description: 'current working directory'
required: true
type: string

jobs:
release-image:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get tag
id: tag
run: |
if [ ${{ github.ref }} == "refs/heads/main" ]; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
fi
- name: Build and push image
working-directory: ${{ inputs.WORKING_DIRECTORY }}
run: make docker-buildx TAG=${{ steps.tag.outputs.tag }}
2 changes: 1 addition & 1 deletion pkg/adapter/nimbus-netpol/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2023 Authors of Nimbus

# Image URL to use all building/pushing image targets
IMG ?= 5gsec/nimbus-cni
IMG ?= 5gsec/nimbus-netpol
# Image Tag to use all building/pushing image targets
TAG ?= v0.1

Expand Down

0 comments on commit ec36c2c

Please sign in to comment.