Some checks failed
Django Helm GitOps Deploy / build-and-deploy (push) Failing after 10s
74 lines
3 KiB
YAML
74 lines
3 KiB
YAML
name: Django Helm GitOps Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
container: catthehacker/ubuntu:act-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
# HINWEIS: Das Terraform-Binary wird über das globale Runner-Volume (:ro)
|
|
# vollautomatisch und manipulationssicher nach /usr/local/bin/terraform injiziert.
|
|
|
|
- name: Trust Local Nginx Certificate Inside Container
|
|
run: |
|
|
mkdir -p /usr/local/share/ca-certificates/
|
|
cp nginx_ssl/nginx.crt /usr/local/share/ca-certificates/nginx-sandbox.crt 2>/dev/null || echo "Nutze Workspace-Zertifikat"
|
|
update-ca-certificates
|
|
|
|
# Nutzt dein Personal Access Token (PAT) für den schnellen Push über den Socket-Port
|
|
- name: Log in to Local Registry
|
|
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login localhost:3005 -u ${{ github.actor }} --password-stdin
|
|
|
|
# Baut das Django-Image und taggt es mit dem eindeutigen Git-SHA
|
|
- name: Build Django Image
|
|
run: |
|
|
docker build -t localhost:3005/${{ github.repository }}:${{ github.sha }} .
|
|
docker build -t localhost:3005/${{ github.repository }}:latest .
|
|
|
|
- name: Push Django Image
|
|
run: |
|
|
docker push localhost:3005/${{ github.repository }}:${{ github.sha }}
|
|
docker push localhost:3005/${{ github.repository }}:latest
|
|
|
|
# Holt die echten K3s-Schlüssel aus dem automatischen Host-Synchronisations-Secret
|
|
- name: Prepare Kubernetes Access
|
|
run: |
|
|
echo "${{ secrets.KUBECONFIG_DATA }}" > ./kind_kubeconfig
|
|
chmod 600 ./kind_kubeconfig
|
|
|
|
# Führt direkt das installierte, performante Zentral-Binary aus
|
|
- name: Terraform Deploy
|
|
run: |
|
|
terraform --version
|
|
terraform init
|
|
terraform apply -auto-approve -var="app_version=${{ github.sha }}"
|
|
|
|
# Überprüft das Deployment im internen Container-Netzwerk und folgt dem Django-Redirect (-L)
|
|
- name: Verify App Health
|
|
run: |
|
|
echo "Warte 15 Sekunden auf die Django-Zertifikate und Migrationen..."
|
|
echo "DEBUG: Sende Request an local-k3s-platform..."
|
|
sleep 15
|
|
curl --fail -L --connect-timeout 5 -H "Host: boday-it.ch" http://local-k3s-platform:80/ || exit 1
|
|
echo "Erfolg: Die Boday-IT Django-Webseite läuft perfekt via Helm im GitOps-Standard!"
|
|
|
|
# DAS FINALE DEINES PRODUKTS: Generiert das anonyme JSON und pusht es mit dem cloudmon-Host-Header
|
|
- name: Publish Map to cloudmon Dashboard
|
|
run: |
|
|
terraform show -json > plan.json
|
|
|
|
curl -X POST \
|
|
-H "Authorization: Bearer boday-cloudmon-super-token-2026" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Host: cloudmon.local" \
|
|
--data-binary @plan.json \
|
|
"http://local-k3s-platform:80/api/v1/push/?repo=${{ github.repository }}"
|
|
|
|
echo "Infrastruktur-Map erfolgreich an cloudmon übermittelt!"
|