Add GitHub Actions workflow to auto-build and publish to deploy branch
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>
This commit is contained in:
parent
060ea937e0
commit
faf85ee68a
2 changed files with 55 additions and 0 deletions
54
.github/workflows/build-deploy.yml
vendored
Normal file
54
.github/workflows/build-deploy.yml
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
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 }}
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,6 +5,7 @@
|
||||||
!/hifi/
|
!/hifi/
|
||||||
!/hifi-src/
|
!/hifi-src/
|
||||||
!/.gitignore
|
!/.gitignore
|
||||||
|
!/.github/
|
||||||
|
|
||||||
# Von Composer/NPM regenerierbare Abhängigkeiten
|
# Von Composer/NPM regenerierbare Abhängigkeiten
|
||||||
/hifi/api/vendor/
|
/hifi/api/vendor/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue