Skip to content

Commit

Permalink
fix(CI): Add job to update image tag in helm charts
Browse files Browse the repository at this point in the history
Signed-off-by: Anurag Rajawat <[email protected]>
  • Loading branch information
Anurag Rajawat committed Sep 26, 2024
1 parent 13df8f9 commit 458f3d8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
32 changes: 31 additions & 1 deletion .github/workflows/stable-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

name: Stable release

on: workflow_dispatch
on:
create:
tags:
- "v*"

permissions: read-all

Expand Down Expand Up @@ -33,8 +36,35 @@ jobs:
NAME: ${{ matrix.adapters }}
secrets: inherit

update-image-tags-in-helm-charts:
if: github.repository == '5GSEC/nimbus'
needs: [ release-nimbus-image, release-adapters-image ]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4

- 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: Update images tag
run: |
./scripts/update-image-tag.sh ${{ steps.tag.outputs.tag }}
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5

release_helm_charts:
if: github.repository == '5GSEC/nimbus'
needs: [ update-image-tags-in-helm-charts ]
permissions:
contents: write
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
##@ Build

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
build: fmt vet ## Build manager binary.
@go build -ldflags="-s" -o bin/"${BINARY_NAME}" ./cmd

.PHONY: run
Expand Down
18 changes: 18 additions & 0 deletions scripts/update-image-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright 2023 Authors of Nimbus

if ! command -v yq >/dev/null; then
echo "Installing yq..."
go install github.com/mikefarah/yq/v4@latest
fi

TAG=$1
DEPLOYMENT_ROOT_DIR="deployments"
DIRECTORIES=("${DEPLOYMENT_ROOT_DIR}/nimbus" "${DEPLOYMENT_ROOT_DIR}/nimbus-k8tls" \
"${DEPLOYMENT_ROOT_DIR}/nimbus-kubearmor" "${DEPLOYMENT_ROOT_DIR}/nimbus-kyverno" "${DEPLOYMENT_ROOT_DIR}/nimbus-netpol")

echo "Updating tag to $TAG"
for directory in "${DIRECTORIES[@]}"; do
yq -i ".image.tag = \"$TAG\"" "${directory}/values.yaml"
done

0 comments on commit 458f3d8

Please sign in to comment.