This commit is contained in:
Hermes
2026-06-04 17:23:49 +00:00
parent c737312ada
commit 7dd8023222
4 changed files with 315 additions and 118 deletions

View File

@@ -1,131 +1,123 @@
name: Deploy Feature Branch to Test
name: Deploy Feature Branch to Test (haus.test.kies-media.de)
on:
push:
branches:
- "feature/**"
workflow_dispatch:
inputs:
ref:
description: "Branch or tag to deploy (default: HEAD)"
required: false
default: ""
jobs:
lint-php:
name: PHP Syntax Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install PHP
run: apt-get update -qq && apt-get install -y -qq php-cli > /dev/null 2>&1
- name: PHP Lint
run: |
errors=0
while IFS= read -r file; do
if ! php -l "$file" > /dev/null 2>&1; then
echo "❌ Syntax error in $file"
php -l "$file"
errors=1
fi
done < <(find . -name "*.php" -not -path "./vendor/*")
if [ "$errors" -eq 1 ]; then
echo "::error::PHP lint check failed"
exit 1
fi
echo "✅ All PHP files pass syntax check"
lint-css:
name: CSS Lint (stylelint)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node.js & stylelint
run: |
apt-get update -qq && apt-get install -y -qq npm nodejs > /dev/null 2>&1
npm install -g stylelint stylelint-config-standard stylelint-prettier > /dev/null 2>&1
- name: CSS Lint
run: |
npx stylelint "**/*.css" --config .stylelintrc.json --allow-empty-input
echo "✅ All CSS files pass lint"
lint-html:
name: HTML Lint (htmlhint)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Node.js & htmlhint
run: |
apt-get update -qq && apt-get install -y -qq npm nodejs > /dev/null 2>&1
npm install -g htmlhint > /dev/null 2>&1
- name: HTML Lint
run: |
npx htmlhint "**/*.html" --config .htmlhintrc
echo "✅ All HTML files pass lint"
deploy:
name: Deploy to Test Environment
runs-on: ubuntu-latest
needs: [lint-php, lint-css, lint-html]
container:
volumes:
- /var/www/test/html:/deploy
concurrency:
group: deploy-test
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Show branch info
- name: Setup SSH
run: |
echo "=== Deploying branch: ${{ gitea.ref_name }} ==="
echo "=== Commit: ${{ gitea.sha }} ==="
echo "=== By: ${{ gitea.actor }} ==="
echo "=== All lint checks passed ✅ ==="
date
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H 188.245.242.194 >> ~/.ssh/known_hosts 2>/dev/null
echo "✅ SSH key configured"
- name: Deploy to test environment
- name: Verify SSH connectivity
run: |
echo "Syncing files to test environment..."
apt-get update -qq && apt-get install -y -qq rsync > /dev/null 2>&1 || true
rsync -av --delete \
ssh -o StrictHostKeyChecking=yes -i ~/.ssh/id_ed25519 \
haustest@188.245.242.194 "echo 'SSH-OK as:' \$(whoami) 'on' \$(hostname)"
- name: Backup current test deployment
run: |
ssh -i ~/.ssh/id_ed25519 haustest@188.245.242.194 \
"cd /home/haustest/htdocs && \
tar czf /home/haustest/backup-pre-deploy-\$(date +%Y%m%d-%H%M%S).tar.gz \
haus.test.kies-media.de && \
ls -lh /home/haustest/backup-pre-deploy-*.tar.gz | tail -1"
- name: Rsync to test environment
run: |
rsync -avz --delete \
--exclude='.git' \
--exclude='node_modules' \
--exclude='tests' \
--exclude='docs' \
--exclude='.gitea' \
--exclude='.husky' \
--exclude='.prettierrc' \
--exclude='.prettierignore' \
--exclude='.stylelintrc.json' \
--exclude='.htmlhintrc' \
--exclude='.gitignore' \
--exclude='.dockerignore' \
--exclude='.continue' \
--exclude='.husky' \
--exclude='Dockerfile' \
--exclude='.dockerignore' \
--exclude='nginx.conf' \
--exclude='eslint.config.js' \
--exclude='package.json' \
--exclude='package-lock.json' \
--exclude='docs/' \
--exclude='phpunit.xml' \
--exclude='scripts' \
--exclude='AGENTS.md' \
--exclude='README.md' \
--exclude='scripts/' \
./ /deploy/
--exclude='CLAUDE.md' \
--exclude='*.md' \
--exclude='.htmlhintrc' \
--exclude='.prettierrc' \
--exclude='.prettierignore' \
--exclude='.stylelintrc.json' \
--exclude='.editorconfig' \
--exclude='.well-known' \
-e "ssh -i ~/.ssh/id_ed25519" \
./ haustest@188.245.242.194:/home/haustest/htdocs/haus.test.kies-media.de/
echo "✅ Deployment complete!"
- name: Set permissions
- name: Smoke test
run: |
chown -R 33:33 /deploy/ 2>/dev/null || true
chmod -R 755 /deploy/ 2>/dev/null || true
echo "✅ Permissions set"
sleep 2
echo "--- HTTP status codes ---"
for path in "/" "/impressum" "/datenschutz"; do
code=$(curl -s -o /dev/null -w "%{http_code}" \
-H "Cache-Control: no-cache" \
"https://haus.test.kies-media.de${path}")
echo " $path → HTTP $code"
if [ "$code" != "200" ]; then
echo "❌ Smoke test failed for $path"
exit 1
fi
done
echo ""
echo "--- Locale switcher present? ---"
if curl -sL "https://haus.test.kies-media.de/" | grep -q "class=\"locale-switcher\""; then
echo " ✅ Locale switcher rendered"
else
echo " ❌ Locale switcher MISSING"
exit 1
fi
echo ""
echo "--- All 4 locales serving? ---"
for loc in de en uk ru; do
lang=$(curl -sL -H "Cache-Control: no-cache" \
-b "locale=$loc" \
"https://haus.test.kies-media.de/" \
| grep -oE '<html lang="[a-z]+"' | head -1)
echo " locale=$loc → $lang"
done
echo ""
echo "🎉 Test deployment verified: https://haus.test.kies-media.de"
- name: Deployment summary
if: always()
run: |
echo "=========================================="
echo " 🚀 Deployment Summary"
echo "=========================================="
echo " Branch: ${{ gitea.ref_name }}"
echo " Commit: ${{ gitea.sha }}"
echo " Target: http://178.104.150.0:6427/"
echo " Lint: ✅ All checks passed"
echo " Time: $(date)"
echo "=========================================="
echo "### 🚀 Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Target:** https://haus.test.kies-media.de" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Server:** haustest@188.245.242.194" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Review URL:** https://haus.test.kies-media.de" >> $GITHUB_STEP_SUMMARY