Files
Lars Stommer 92ccf40312
Deploy / test (push) Failing after 15s
Deploy / deploy (push) Skipped
CI: Host-Umgebung vor PHP-Setup prüfen und Self-hosted-Modus setzen
2026-10-26 08:31:46 +01:00

135 lines
4.3 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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
on:
push:
branches: [main]
tags: ['v*']
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'
runs-on: ubuntu-latest
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
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
- name: SSH key
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
- name: Deploy
env:
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 }}
run: |
export DEPLOY_SSH_KEY="$HOME/.ssh/deploy_key"
bash scripts/deploy.sh "${{ inputs.environment || 'production' }}" deploy