Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
74 changes: 74 additions & 0 deletions .github/workflows/helm-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Lint/Builds/Push Helm charts to Github Registry

on:
pull_request:
push:
branches:
- main
paths:
- 'toggle/**'

permissions:
packages: write

jobs:
build:
name: Publish Helm
runs-on: ubuntu-latest
strategy:
matrix:
include:
- chart: react-serve

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Helm
uses: azure/setup-helm@v3

# Lint/Build
- name: Helm dependency
working-directory: ./toggle/${{ matrix.chart }}
run: |
yq --indent 0 '.dependencies | map(["helm", "repo", "add", .name, .repository] | join(" ")) | .[]' ./Chart.lock | sh --
helm dependency build ./

- name: 🐳 Helm lint
working-directory: ./toggle/${{ matrix.chart }}
run: helm lint ./ --values ./values-test.yaml

- name: 🐳 Helm template
working-directory: ./toggle/${{ matrix.chart }}
run: helm template ./ --values ./values-test.yaml

# Publish
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: ${{ github.event_name == 'push' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Package Helm Chart
working-directory: ./toggle/${{ matrix.chart }}
if: ${{ github.event_name == 'push' }}
run: |
helm package ./ -d .helm-charts

- name: Push Helm Chart
working-directory: ./toggle/${{ matrix.chart }}
if: ${{ github.event_name == 'push' }}
env:
OCI_REPO: oci://ghcr.io/${{ github.repository }}
run: |
OCI_REPO=$(echo $OCI_REPO | tr '[:upper:]' '[:lower:]')
PACKAGE_FILE=$(ls .helm-charts/*.tgz | head -n 1)
echo "## Helm Chart" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Helm push output:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
helm push "$PACKAGE_FILE" $OCI_REPO >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.helm-charts
1 change: 1 addition & 0 deletions toggle/react-serve/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
values-local.yaml
1 change: 1 addition & 0 deletions toggle/react-serve/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
values-local.yaml
7 changes: 7 additions & 0 deletions toggle/react-serve/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: react-serve
description: "Basic Helm Chart to deploy React Web App"
type: application
version: 0.0.1
sources:
- https://github.com/toggle-corp/charts
41 changes: 41 additions & 0 deletions toggle/react-serve/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "react-serve.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-label-names
*/}}
{{- define "react-serve.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "react-serve.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return the proper MinIO® image name
*/}}
{{- define "react-serve.container_image" -}}
{{- $imageName := required ".Values.image.name" .Values.image.name -}}
{{- $imageTag := required ".Values.image.tag" .Values.image.tag -}}
{{- printf "%s:%s" $imageName $imageTag -}}
{{- end -}}
13 changes: 13 additions & 0 deletions toggle/react-serve/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ template "react-serve.fullname" . }}-configmap
labels:
component: web-app-deployment
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
data:
# Provided configs using env
{{- range $name, $value := .Values.env }}
{{ $name }}: {{ $value | quote }}
{{- end }}
38 changes: 38 additions & 0 deletions toggle/react-serve/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "react-serve.fullname" . }}
labels:
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ template "react-serve.fullname" . }}
release: {{ .Release.Name }}
run: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "react-serve.fullname" . }}
release: {{ .Release.Name }}
run: {{ .Release.Name }}
spec:
{{- with .Values.image.pullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Values.container.name }}
image: {{ include "react-serve.container_image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.container.port }}
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ template "react-serve.fullname" . }}-configmap
32 changes: 32 additions & 0 deletions toggle/react-serve/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.ingress.enabled }}

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ template "react-serve.fullname" . }}-ingress
labels:
app: {{ template "react-serve.name" . }}
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
spec:
ingressClassName: {{ required "ingress.ingressClassName" .Values.ingress.ingressClassName | quote }}
rules:
- host: {{ required "ingress.hostname" .Values.ingress.hostname | quote }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ template "react-serve.fullname" . }}-svc
port:
number: 80

{{- if .Values.ingress.tls.enabled }}
tls:
- hosts:
- {{ .Values.ingress.host | quote }}
secretName: {{ required "ingress.tls.secretName" .Values.ingress.tls.secretName }}
{{- end }}

{{- end }}
18 changes: 18 additions & 0 deletions toggle/react-serve/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "react-serve.fullname" . }}-svc
labels:
app: {{ template "react-serve.fullname" . }}
environment: {{ .Values.environment }}
release: {{ .Release.Name }}
spec:
type: ClusterIP
selector:
app: {{ template "react-serve.fullname" . }}
release: {{ .Release.Name }}
run: {{ .Release.Name }}
ports:
- protocol: TCP
port: 80
targetPort: {{ .Values.container.port }}
14 changes: 14 additions & 0 deletions toggle/react-serve/values-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
fullnameOverride: test-123

image:
name: github.local/react/web-app
tag: latest
pullPolicy: Always

ingress:
hostname: react.web-app.com
ingressClassName: nginx

env:
APP_TITLE: "My APP"
APP_ENVIRONMENT: ALPHA
71 changes: 71 additions & 0 deletions toggle/react-serve/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
environment: prod

fullnameOverride:

## React image (static servied by nginx)
## @param image.name Container image name
## @param image.tag Container image tag
## @param image.pullPolicy Container pull policy `Always|IfNotPresent|Never`
## @param image.pullSecrets Container image pull secrets
##
image:
name:
tag:
pullPolicy: IfNotPresent
pullSecrets:

## React container
## @param container.name Container name
## @param container.port Container port
##
container:
name: react-serve
port: 80

## @param resources Set container requests and limits for different resources like CPU or memory
## Example:
## resources:
## requests:
## cpu: 2
## memory: 512Mi
## limits:
## cpu: 3
## memory: 1024Mi
##
resources:
requests:
cpu: "0.5"
memory: "100Mi"
limits:
cpu: "1"
memory: "100Mi"

ingress:
## @param ingress.enabled Enable an ingress resource
##
enabled: true
## @param ingress.ingressClassName Defines which ingress controller will implement the resource
##
ingressClassName:
## @param ingress.hostname Ingress hostname for the ingress
## Hostname must be provided if Ingress is enabled.
##
hostname:
## @param ingress.tls Ingress TLS configuration
##
tls:
## @param ingress.tls.enabled Enable an tls for ingress resource
##
enabled: false
## @param ingress.tls.secretName Ingress TLS secrets name
## secretName must be provided if Ingress TLS is enabled.
##
secretName:

## @param env with environment variables to pass to the container
## e.g:
## env:
## APP_TITLE: "My React APP"
## APP_ENVIRONMENT: "ALPHA"
##
env:
Loading