FeWo als Pilot an den eigenständigen PipelineManager anbinden

This commit is contained in:
Lars Stommer committed 2026-10-26 13:27:52 +01:00
1 parent 92ccf40312
commit 8eae37e11d
6 files changed
+127 -126

No files matched your search

+45 -117
View File
@@ -1,134 +1,62 @@
# Tests on every push; deployment to Strato for tags "v*" or by hand (Gitea › Actions › Deploy › Run workflow).
# Needs a Gitea act_runner (e.g. on the private server) and these repository secrets:
# DEPLOY_SSH_KEY private key whose public key is stored at Strato (SFTP & SSH)
# DEPLOY_HOST package-specific SSH server, e.g. 51539426.ssh.w1.strato.hosting (not ssh.strato.de)
# DEPLOY_USER SSH user from the Strato customer login
# DEPLOY_PATH e.g. fewo-production
# DEPLOY_PHP e.g. /opt/RZphp84/bin/php-cli
# DEPLOY_URL e.g. https://www.fewo-stommer.de
name: Deploy
name: Deploy FeWo mit PipelineManager
on:
push:
branches: [main]
tags: ['v*']
branches: [develop, main]
workflow_dispatch:
inputs:
environment:
description: Ziel
type: choice
options: [production, staging]
default: production
jobs:
test:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:11.8
env:
MARIADB_DATABASE: fewo_test
MARIADB_ROOT_PASSWORD: test
ports: ['3306:3306']
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=5s --health-timeout=5s --health-retries=20
steps:
- uses: actions/checkout@v4
- name: Runner-Umgebung prüfen
shell: bash
run: |
uname -m
cat /etc/os-release
id
if command -v php >/dev/null 2>&1; then
php --version
else
echo 'PHP ist noch nicht im PATH.'
fi
if command -v apt-cache >/dev/null 2>&1; then
apt-cache policy php8.4 php8.4-cli php8.4-dev
fi
if [ "$(id -u)" = 0 ]; then
echo 'Runner läuft als root.'
elif command -v sudo >/dev/null 2>&1 && sudo -n true; then
echo 'Passwortloses sudo ist verfügbar.'
else
echo '::error::setup-php benötigt auf diesem Host passwortloses sudo; der Runner hat es nicht.'
exit 1
fi
# act_runner v0.2.11 supports Node 20; newer setup-php releases require Node 24.
- uses: shivammathur/setup-php@2.36.0
with:
php-version: '8.4'
extensions: mbstring, intl, gd, exif, zip, pdo_sqlite, sqlite3, pdo_mysql, fileinfo, openssl
tools: composer:v2
env:
runner: self-hosted
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
- name: Install
run: |
composer install --no-interaction --no-progress --prefer-dist
npm ci --no-audit --no-fund
npm run build
cp .env.example .env
php artisan key:generate
- name: Tests (SQLite)
run: php artisan test --compact --testsuite=Feature
- name: Tests (MariaDB 11.8, wie auf Strato)
env:
DB_CONNECTION: mariadb
DB_HOST: 127.0.0.1
DB_PORT: '3306'
DB_DATABASE: fewo_test
DB_USERNAME: root
DB_PASSWORD: test
run: php artisan test --compact --testsuite=Feature
deploy:
needs: test
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
# Raspi5-Paperless: existing host runner; all PHP/Node work happens inside the image.
runs-on: ubuntu-latest
env:
PIPELINE_IMAGE: pipeline-manager:0.1.0
PIPELINE_HOME: /home/lars/docker/pipeline-manager
steps:
- uses: actions/checkout@v4
# Keep the runtime compatible with the test job and the installed act_runner.
- uses: shivammathur/setup-php@2.36.0
with:
php-version: '8.4'
extensions: mbstring, intl, gd, exif, zip, fileinfo, openssl
tools: composer:v2
env:
runner: self-hosted
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
- name: SSH key
- name: Anwendung im Manager-Container vorbereiten und testen
id: build
run: |
mkdir -p ~/.ssh
printf '%s\n' "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -H "${{ secrets.DEPLOY_HOST }}" >> ~/.ssh/known_hosts
set -eu
case "$GITHUB_REF" in
refs/heads/develop) TARGET=staging ;;
refs/heads/main) TARGET=production ;;
*) echo 'Unzulässiger Branch'; exit 1 ;;
esac
docker image inspect "$PIPELINE_IMAGE" >/dev/null
STATUS=0
docker run --rm --user "$(id -u):$(id -g)" \
-v "$(pwd -P):/workspace:ro" "$PIPELINE_IMAGE" \
pipeline-manager check --environment "$TARGET" || STATUS=$?
if [ "$STATUS" = 3 ]; then
echo 'enabled=false' >> "$GITHUB_OUTPUT"
exit 0
fi
test "$STATUS" = 0
umask 077
mkdir -p "$PIPELINE_HOME/cache/composer" "$PIPELINE_HOME/cache/npm" "$PIPELINE_HOME/backups" .pipeline
docker run --rm --user "$(id -u):$(id -g)" --cpus=2 --memory=2g --pids-limit=512 \
-e HOME=/tmp \
-v "$(pwd -P):/workspace" \
-v "$PIPELINE_HOME/cache:/cache" "$PIPELINE_IMAGE" \
pipeline-manager prepare
echo "target=$TARGET" >> "$GITHUB_OUTPUT"
echo 'enabled=true' >> "$GITHUB_OUTPUT"
- name: Deploy
- name: Sichern und nach Strato übertragen
if: steps.build.outputs.enabled == 'true'
env:
TARGET: ${{ steps.build.outputs.target }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
DEPLOY_PHP: ${{ secrets.DEPLOY_PHP }}
DEPLOY_URL: ${{ secrets.DEPLOY_URL }}
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
run: |
export DEPLOY_SSH_KEY="$HOME/.ssh/deploy_key"
bash scripts/deploy.sh "${{ inputs.environment || 'production' }}" deploy
set -eu
docker run --rm --user "$(id -u):$(id -g)" --cpus=1 --memory=512m --pids-limit=128 \
-e GITHUB_REF -e GITHUB_SHA -e DEPLOY_HOST -e DEPLOY_USER -e DEPLOY_SSH_KEY -e DEPLOY_KNOWN_HOSTS \
-v "$(pwd -P):/workspace:ro" \
-v "$PIPELINE_HOME/backups:/backups" "$PIPELINE_IMAGE" \
pipeline-manager deploy --environment "$TARGET" --backup-root /backups