From 9830875e3671b6cbce0b2a2a155cc07f6c627898 Mon Sep 17 00:00:00 2001 From: Melchior Reimers Date: Wed, 4 Feb 2026 19:33:46 +0100 Subject: [PATCH] updated ci/cd --- .gitea/workflows/deploy.yaml | 47 ++++++++++++++---------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 3ac2eda..cf2860d 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -10,15 +10,10 @@ jobs: steps: - name: Validate deployment secrets env: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} SSH_PUBLIC_KEY: ${{ secrets.SSH_PUBLIC_KEY }} HETZNER_TOKEN: ${{ secrets.HETZNER_TOKEN }} run: | set -e - if [ -z "$SSH_PRIVATE_KEY" ]; then - echo "Missing SSH_PRIVATE_KEY secret" - exit 1 - fi if [ -z "$SSH_PUBLIC_KEY" ]; then echo "Missing SSH_PUBLIC_KEY secret" exit 1 @@ -27,28 +22,22 @@ jobs: echo "Missing HETZNER_TOKEN secret" exit 1 fi - - name: Deploy via SSH - uses: appleboy/ssh-action@v0.1.10 - with: - host: 172.17.0.1 - username: root - key: ${{ secrets.SSH_PRIVATE_KEY }} - # Wir übergeben die Secrets als Environment-Variablen an den SSH-Befehl - envs: HETZNER_TOKEN,SSH_KEY - script: | - set -e - cd /root/iac - git fetch origin main && git reset --hard origin/main - - # Kopiere das Template und ersetze die Platzhalter mit sed - cp terraform.tfvars.example terraform.tfvars - sed -i "s|__HCLOUD_TOKEN__|${HETZNER_TOKEN}|g" terraform.tfvars - sed -i "s|__SSH_KEY__|${SSH_KEY}|g" terraform.tfvars - - terraform init - terraform apply -auto-approve - - echo "Deployment successful" + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Terraform + uses: hashicorp/setup-terraform@v3 + - name: Deploy with Terraform env: - HETZNER_TOKEN : ${{ secrets.HETZNER_TOKEN }} - SSH_KEY: ${{ secrets.SSH_PUBLIC_KEY }} \ No newline at end of file + HETZNER_TOKEN: ${{ secrets.HETZNER_TOKEN }} + SSH_KEY: ${{ secrets.SSH_PUBLIC_KEY }} + run: | + set -e + # Kopiere das Template und ersetze die Platzhalter mit sed + cp terraform.tfvars.example terraform.tfvars + sed -i "s|__HCLOUD_TOKEN__|${HETZNER_TOKEN}|g" terraform.tfvars + sed -i "s|__SSH_KEY__|${SSH_KEY}|g" terraform.tfvars + + terraform init + terraform apply -auto-approve + + echo "Deployment successful" \ No newline at end of file