Baut bei jedem Push auf main automatisch das PHP-Backend (composer install) und das React-Frontend (npm run build), und veroeffentlicht das fertige Ergebnis im "deploy"-Branch. Plesk kann diesen Branch ziehen, ohne selbst Composer/npm ausfuehren zu muessen - kein manuelles Hochladen von Build-Artefakten mehr noetig. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
54 lines
1.5 KiB
YAML
54 lines
1.5 KiB
YAML
name: Build and deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.2'
|
|
|
|
- name: Composer install
|
|
working-directory: hifi/api
|
|
run: composer install --no-dev --optimize-autoloader --no-interaction
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: hifi-src/package-lock.json
|
|
|
|
- name: npm build
|
|
working-directory: hifi-src
|
|
run: |
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: Publish build output to deploy branch
|
|
working-directory: hifi
|
|
run: |
|
|
# Sicherheitsnetz: diese Dateien sind umgebungsspezifisch und dürfen
|
|
# niemals in irgendeinen Branch gelangen, auch nicht versehentlich.
|
|
rm -f api/config/db.php api/config/setup.php
|
|
|
|
git init -q -b deploy
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add -A
|
|
git commit -q -m "Deploy build from ${GITHUB_SHA::7}"
|
|
git push --force "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:deploy
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|