This commit is contained in:
@@ -10,15 +10,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Validate deployment secrets
|
- name: Validate deployment secrets
|
||||||
env:
|
env:
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
||||||
SSH_PUBLIC_KEY: ${{ secrets.SSH_PUBLIC_KEY }}
|
SSH_PUBLIC_KEY: ${{ secrets.SSH_PUBLIC_KEY }}
|
||||||
HETZNER_TOKEN: ${{ secrets.HETZNER_TOKEN }}
|
HETZNER_TOKEN: ${{ secrets.HETZNER_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
if [ -z "$SSH_PRIVATE_KEY" ]; then
|
|
||||||
echo "Missing SSH_PRIVATE_KEY secret"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -z "$SSH_PUBLIC_KEY" ]; then
|
if [ -z "$SSH_PUBLIC_KEY" ]; then
|
||||||
echo "Missing SSH_PUBLIC_KEY secret"
|
echo "Missing SSH_PUBLIC_KEY secret"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -27,28 +22,22 @@ jobs:
|
|||||||
echo "Missing HETZNER_TOKEN secret"
|
echo "Missing HETZNER_TOKEN secret"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
- name: Deploy via SSH
|
- name: Checkout
|
||||||
uses: appleboy/ssh-action@v0.1.10
|
uses: actions/checkout@v4
|
||||||
with:
|
- name: Setup Terraform
|
||||||
host: 172.17.0.1
|
uses: hashicorp/setup-terraform@v3
|
||||||
username: root
|
- name: Deploy with Terraform
|
||||||
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"
|
|
||||||
env:
|
env:
|
||||||
HETZNER_TOKEN : ${{ secrets.HETZNER_TOKEN }}
|
HETZNER_TOKEN: ${{ secrets.HETZNER_TOKEN }}
|
||||||
SSH_KEY: ${{ secrets.SSH_PUBLIC_KEY }}
|
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"
|
||||||
Reference in New Issue
Block a user