# 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 - uses: shivammathur/setup-php@v2 with: php-version: '8.4' extensions: mbstring, intl, gd, exif, zip, pdo_sqlite, sqlite3, pdo_mysql, fileinfo, openssl tools: composer:v2 - 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 - 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 deploy: needs: test if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: '8.4' extensions: mbstring, intl, gd, exif, zip, fileinfo, openssl tools: composer:v2 - 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