Skip to content

i15-1: Update cs-web-lib #61

i15-1: Update cs-web-lib

i15-1: Update cs-web-lib #61

Workflow file for this run

name: Build & Publish Web App (Docker + Helm)
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Release tag in the form appName@x.y.z"
required: true
type: string
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
parse-tag:
name: Parse app name and version
runs-on: ubuntu-latest
outputs:
app: ${{ steps.parse.outputs.app }}
version: ${{ steps.parse.outputs.version }}
steps:
- name: Determine tag
id: tag
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
else
echo "TAG=${{ inputs.tag }}" >> $GITHUB_ENV
fi
- name: Parse tag
id: parse
run: |
TAG="${TAG}"
if [[ ! "$TAG" =~ ^[^@]+@(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*))?(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$ ]]; then
echo "Invalid tag format: $TAG"
exit 1
fi
APP="${TAG%@*}" # remove shortest match of @* from the end of $TAG
VERSION="${TAG#*@}" # remove the shortest match *@ from the start of $TAG
echo "app=$APP" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
docker:
name: Build & Push Docker image
runs-on: ubuntu-latest
needs: parse-tag
steps:
- uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Normalise repository name to lowercase
id: repo
run: |
echo "repo_lc=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile.web-app
push: true
build-args: |
APP_NAME=${{ needs.parse-tag.outputs.app }}
tags: |
${{ env.REGISTRY }}/${{ steps.repo.outputs.repo_lc }}/${{ needs.parse-tag.outputs.app }}:${{ needs.parse-tag.outputs.version }}
${{ env.REGISTRY }}/${{ steps.repo.outputs.repo_lc }}/${{ needs.parse-tag.outputs.app }}:latest
helm:
name: Package & Push Helm chart
runs-on: ubuntu-latest
needs: parse-tag
steps:
- uses: actions/checkout@v4
- name: Install Helm
uses: azure/setup-helm@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v3.14.0
- name: Log in to GHCR (Helm OCI)
run: |
echo ${{ secrets.GITHUB_TOKEN }} | \
helm registry login ghcr.io \
--username ${{ github.repository_owner }} \
--password-stdin
- name: Normalise repository name to lowercase
id: repo
run: |
echo "repo_lc=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Sync versions in Chart and Values
run: |
CHART_DIR="apps/${{ needs.parse-tag.outputs.app }}/helm"
VERSION="${{ needs.parse-tag.outputs.version }}"
# 1. Update Chart.yaml
yq -i ".version = \"$VERSION\" | .appVersion = \"$VERSION\"" "$CHART_DIR/Chart.yaml"
# 2. Update the image tag in values.yaml
yq -i ".ui-base.image.tag = \"$VERSION\"" "$CHART_DIR/values.yaml"
- name: Build base chart dependencies
run: |
helm dependency build ./helm
- name: Build chart dependencies
run: |
CHART_DIR="apps/${{ needs.parse-tag.outputs.app }}/helm"
helm dependency build "$CHART_DIR"
- name: Package chart
run: |
CHART_DIR="apps/${{ needs.parse-tag.outputs.app }}/helm"
helm package "$CHART_DIR" \
--version "${{ needs.parse-tag.outputs.version }}" \
--app-version "${{ needs.parse-tag.outputs.version }}"
- name: Push chart
run: |
CHART_PACKAGE=$(ls *.tgz)
helm push "$CHART_PACKAGE" \
oci://${{ env.REGISTRY }}/${{ steps.repo.outputs.repo_lc }}/charts