feat: Update workflows for Token-based Git clone

This commit is contained in:
Sebastian Serfling
2026-05-07 14:56:37 +02:00
parent 4d5020ab7b
commit 7c1b9a5e40
4 changed files with 77 additions and 43 deletions
+11 -14
View File
@@ -7,26 +7,23 @@ on:
jobs:
production:
runs-on: ubuntu-latest
runs-on: production
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: SSH Key einrichten
- name: Configure Git Token
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
echo "${{ secrets.PROD_HOST_KEY }}" >> ~/.ssh/known_hosts
git config --global url."https://sebastian.serfling:${{ secrets.GIT_TOKEN }}@gitlab.stines.de/".insteadOf "https://gitlab.stines.de/"
- name: Hugo Build
run: hugo --minify --source ./hugo
- name: Deploy auf Production
- name: Hugo Build & Deploy
run: |
rsync -az --delete \
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
./hugo/public/ \
root@${{ secrets.PROD_IP }}:/var/www/html/
set -e
# Hugo Build direkt in /var/www/html
hugo --minify --source ./hugo -d /var/www/html
echo "✅ Production Hugo Build erfolgreich!"
echo "🚀 Live unter https://stines.de"
+33 -15
View File
@@ -7,14 +7,14 @@ on:
jobs:
staging:
runs-on: ubuntu-latest
runs-on: proxmox
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
- name: Terraform Init & Apply (Staging LXC)
- name: Terraform Init & Apply (Staging LXC erstellen)
working-directory: terraform
run: |
terraform init
@@ -23,25 +23,43 @@ jobs:
-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_public_key=${{ secrets.DEPLOY_SSH_PUBKEY }}" \
-var="ssh_private_key=${{ secrets.DEPLOY_SSH_KEY }}"
env:
TF_IN_AUTOMATION: "true"
- name: SSH Key einrichten
- name: Warte auf LXC Boot
run: sleep 30
- name: SSH Key Setup
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
echo "${{ secrets.STAGING_HOST_KEY }}" >> ~/.ssh/known_hosts
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 Build
run: hugo --minify --source ./hugo
- name: Deploy auf Staging
- name: Hugo Clone & Build auf Staging-LXC
run: |
rsync -az --delete \
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
./hugo/public/ \
root@${{ secrets.STAGING_IP_PLAIN }}:/var/www/html/
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