From 5babdb1ef418ba50a9c6a3ccd51c19b9f0b48f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Faguet?= Date: Thu, 7 May 2026 15:59:27 +0200 Subject: [PATCH] feat: CI --- .forgejo/workflows/deploy.yaml | 50 +++++++++++++++++++++++++++ charts/Chart.yaml | 6 ++++ charts/templates/deployment-hugo.yaml | 32 +++++++++++++++++ charts/templates/ingress.yaml | 20 +++++++++++ charts/values.yaml | 4 +++ 5 files changed, 112 insertions(+) create mode 100644 .forgejo/workflows/deploy.yaml create mode 100644 charts/Chart.yaml create mode 100644 charts/templates/deployment-hugo.yaml create mode 100644 charts/templates/ingress.yaml create mode 100644 charts/values.yaml diff --git a/.forgejo/workflows/deploy.yaml b/.forgejo/workflows/deploy.yaml new file mode 100644 index 0000000..c57b91e --- /dev/null +++ b/.forgejo/workflows/deploy.yaml @@ -0,0 +1,50 @@ +on: + push: + branches: [main] + pull_request: + +jobs: + build-and-deploy: + runs-on: koda-k8s + env: + NAMESPACE: siwa-game-prd + REGISTRY: siwa-game + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Helm lint charts + run: | + helm lint charts + + - name: Docker login + run: | + docker login $REGISTRY_URL -u $REGISTRY_USER --password "$REGISTRY_PASS" + + - name: Build and push hugo + run: | + docker build --progress=plain -t $REGISTRY_URL/$REGISTRY/clem-hugo:${{ github.sha }} . + docker push $REGISTRY_URL/$REGISTRY/clem-hugo:${{ github.sha }} + + - name: Ensure namespace exists + run: | + kubectl get ns $NAMESPACE || kubectl create namespace $NAMESPACE + + - name: Delete existing imagePullSecret (if exists) + run: | + kubectl delete secret registry-creds -n $NAMESPACE --ignore-not-found + + - name: Copy imagePullSecret to namespace + run: | + kubectl get secret registry-creds -n servadmin -o yaml \ + | sed "s/namespace: servadmin/namespace: $NAMESPACE/" \ + | kubectl apply -f - + + + - name: Deploy with Helm + run: | + helm upgrade --install hugo charts \ + --namespace $NAMESPACE \ + --set hugo.repository=$REGISTRY_URL/$REGISTRY/clem-hugo \ + --set hugo.tag=${{ github.sha }} \ + --set hugo.domain=preprod.siwa-game.fr diff --git a/charts/Chart.yaml b/charts/Chart.yaml new file mode 100644 index 0000000..1707f37 --- /dev/null +++ b/charts/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: hugo +description: Helm chart to deploy Hugo static site +type: application +version: 0.1.0 +appVersion: "1.0" diff --git a/charts/templates/deployment-hugo.yaml b/charts/templates/deployment-hugo.yaml new file mode 100644 index 0000000..440d369 --- /dev/null +++ b/charts/templates/deployment-hugo.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hugo +spec: + replicas: 1 + selector: + matchLabels: + app: hugo + template: + metadata: + labels: + app: hugo + spec: + containers: + - name: hugo + image: {{ .Values.hugo.repository }}:{{ default "latest" .Values.hugo.tag }} + ports: + - containerPort: 80 + imagePullSecrets: + - name: registry-creds +--- +apiVersion: v1 +kind: Service +metadata: + name: hugo +spec: + selector: + app: hugo + ports: + - port: 80 + targetPort: 80 diff --git a/charts/templates/ingress.yaml b/charts/templates/ingress.yaml new file mode 100644 index 0000000..f7386cf --- /dev/null +++ b/charts/templates/ingress.yaml @@ -0,0 +1,20 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: hugo-ingress + annotations: + traefik.ingress.kubernetes.io/router.entrypoints: websecure + traefik.ingress.kubernetes.io/router.tls: "true" + traefik.ingress.kubernetes.io/router.tls.certresolver: le +spec: + rules: + - host: "{{ .Values.hugo.domain }}" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: hugo + port: + number: 80 diff --git a/charts/values.yaml b/charts/values.yaml new file mode 100644 index 0000000..41991c2 --- /dev/null +++ b/charts/values.yaml @@ -0,0 +1,4 @@ +hugo: + domain: "" + repository: "" + tag: ""