72 lines
2.2 KiB
YAML
72 lines
2.2 KiB
YAML
name: Deploy Staging
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
staging:
|
|
runs-on: proxmox
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
submodules: true
|
|
|
|
- name: Delete alte Staging VM (CT 200)
|
|
run: |
|
|
pct destroy 200 --force || true
|
|
sleep 3
|
|
|
|
- name: Terraform Init & Apply (Staging LXC erstellen)
|
|
working-directory: terraform
|
|
run: |
|
|
terraform init
|
|
terraform apply -auto-approve \
|
|
-var="proxmox_host=${{ secrets.PROXMOX_HOST }}" \
|
|
-var="proxmox_token_id=${{ secrets.PROXMOX_TOKEN_ID }}" \
|
|
-var="proxmox_token_secret=${{ secrets.PROXMOX_TOKEN_SECRET }}" \
|
|
-var="proxmox_node=${{ secrets.PROXMOX_NODE }}" \
|
|
-var="lxc_bridge=vmbr2" \
|
|
-var="staging_ip=${{ secrets.STAGING_IP }}" \
|
|
-var="staging_gw=${{ secrets.STAGING_GW }}" \
|
|
-var="ssh_public_key=${{ secrets.DEPLOY_SSH_PUBKEY }}" \
|
|
-var="ssh_private_key=${{ secrets.DEPLOY_SSH_KEY }}" \
|
|
-var="root_password=${{ secrets.ROOT_PASSWORD }}"
|
|
env:
|
|
TF_IN_AUTOMATION: "true"
|
|
|
|
- name: Warte auf LXC Boot
|
|
run: sleep 30
|
|
|
|
- name: SSH Key Setup
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.DEPLOY_SSH_KEY }}" | base64 -d > ~/.ssh/staging_key
|
|
chmod 600 ~/.ssh/staging_key
|
|
ssh-keyscan -H ${{ secrets.STAGING_IP }} >> ~/.ssh/known_hosts 2>/dev/null || true
|
|
|
|
- name: Hugo Clone & Build auf Staging-LXC
|
|
run: |
|
|
ssh -i ~/.ssh/staging_key -o StrictHostKeyChecking=no deploy@${{ secrets.STAGING_IP }} bash << 'EOF'
|
|
set -e
|
|
cd /tmp
|
|
|
|
# Repository clonen mit Token (oder updaten falls existiert)
|
|
GIT_URL="https://sebastian.serfling:${{ secrets.GIT_TOKEN }}@gitlab.stines.de/sebastian.serfling/Webseite_Stines.git"
|
|
|
|
if [ -d "webseite" ]; then
|
|
cd webseite
|
|
git pull origin main
|
|
else
|
|
git clone "$GIT_URL" webseite
|
|
cd webseite
|
|
fi
|
|
|
|
# Hugo Build direkt in /var/www/html
|
|
hugo --minify --source ./hugo -d /var/www/html
|
|
|
|
echo "✅ Staging Hugo Build erfolgreich!"
|
|
EOF
|