This commit is contained in:
@@ -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,19 +22,16 @@ 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: |
|
||||
- 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 }}
|
||||
run: |
|
||||
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
|
||||
@@ -49,6 +41,3 @@ jobs:
|
||||
terraform apply -auto-approve
|
||||
|
||||
echo "Deployment successful"
|
||||
env:
|
||||
HETZNER_TOKEN : ${{ secrets.HETZNER_TOKEN }}
|
||||
SSH_KEY: ${{ secrets.SSH_PUBLIC_KEY }}
|
||||
Reference in New Issue
Block a user