diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml new file mode 100644 index 0000000..ec1a06b --- /dev/null +++ b/.github/workflows/build-deploy.yml @@ -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 }} diff --git a/.gitignore b/.gitignore index 68182b7..b1a16b0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ !/hifi/ !/hifi-src/ !/.gitignore +!/.github/ # Von Composer/NPM regenerierbare Abhängigkeiten /hifi/api/vendor/