my-app-sandbox/.github/workflows/deploy.yml
bast 5b6a70e1e5
Some checks failed
Build, Push and GitOps Deploy / test-and-deploy (push) Failing after 7s
.github/workflows/deploy.yml aktualisiert
2026-10-31 01:57:03 +00:00

51 lines
1.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Build, Push and GitOps Deploy
on:
push:
branches: [ "main" ]
workflow_dispatch:
jobs:
test-and-deploy:
runs-on: ubuntu-latest
container: catthehacker/ubuntu:act-latest
steps:
# KORRIGIERT: Installiert OpenTofu statt Terraform – sicher gegen Rate-Limits!
- name: Install OpenTofu (Terraform Drop-In Replacement)
run: |
apt-get update && apt-get install -y curl
curl --proto '=https' --tlsv1.2 -fsSL https://opentofu.org | sh
# Wir erstellen einen Symlink, damit deine Pipeline 'terraform' fehlerfrei ausführen kann
ln -s /usr/local/bin/tofu /usr/local/bin/terraform
terraform --version
- name: Checkout Code
uses: actions/checkout@v4
- name: Log in to Local Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login forgejo:3000 -u ${{ github.actor }} --password-stdin
- name: Inject Version into Dockerfile
run: sed -i "s/{{APP_VERSION}}/${{ github.sha }}/g" Dockerfile
- name: Build App Image
run: |
docker build -t forgejo:3000/${{ github.repository }}:${{ github.sha }} .
docker build -t forgejo:3000/${{ github.repository }}:latest .
- name: Push App Image
run: |
docker push forgejo:3000/${{ github.repository }}:${{ github.sha }}
docker push forgejo:3000/${{ github.repository }}:latest
- name: Terraform Deploy
run: |
terraform init
terraform apply -auto-approve -var="app_version=${{ github.sha }}"
- name: Verify App Health
run: |
echo "Warte auf das Ingress-Routing..."
sleep 15
curl --fail --connect-timeout 5 http://local-k3s-platform:80/ || exit 1
echo "Erfolg: Die App läuft fehlerfrei nach dem Update!"