2026-08-17 13:30:49 +02:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: ['release/*']
|
|
|
|
|
pull_request:
|
|
|
|
|
branches: [main, 'release/*']
|
|
|
|
|
|
|
|
|
|
jobs:
|
2026-08-17 23:13:43 +02:00
|
|
|
ci-image:
|
|
|
|
|
runs-on: docker
|
|
|
|
|
container:
|
|
|
|
|
image: catthehacker/ubuntu:act-latest
|
|
|
|
|
outputs:
|
|
|
|
|
tag: ${{ steps.meta.outputs.tag }}
|
|
|
|
|
steps:
|
|
|
|
|
- uses: https://data.forgejo.org/actions/checkout@v4
|
|
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
|
uses: https://data.forgejo.org/docker/setup-buildx-action@v3
|
|
|
|
|
|
|
|
|
|
- name: Login to Forgejo Registry
|
|
|
|
|
uses: https://data.forgejo.org/docker/login-action@v3
|
|
|
|
|
with:
|
|
|
|
|
registry: forge.lvl0.xyz
|
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
|
|
|
|
|
|
- name: Compute image tag from lockfile
|
|
|
|
|
id: meta
|
|
|
|
|
run: |
|
2026-08-19 19:32:08 +02:00
|
|
|
HASH="$(cat composer.lock package-lock.json | sha256sum | cut -c1-12)"
|
2026-08-17 23:13:43 +02:00
|
|
|
echo "tag=php8.3-${HASH}" >> "$GITHUB_OUTPUT"
|
|
|
|
|
|
2026-08-19 14:33:45 +02:00
|
|
|
- name: Check whether image already exists
|
|
|
|
|
id: exists
|
|
|
|
|
run: |
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
TOKEN="$(curl -sf "https://forge.lvl0.xyz/v2/token?service=container_registry&scope=repository:lvl0/dishplanner-ci:pull" | grep -o '"token":"[^"]*"' | head -n1 | cut -d'"' -f4)"
|
|
|
|
|
if [ -z "$TOKEN" ]; then
|
|
|
|
|
echo "Registry token fetch failed; cannot check for an existing image." >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
CODE="$(curl -s -o /dev/null -w '%{http_code}' \
|
|
|
|
|
-H "Authorization: Bearer $TOKEN" \
|
|
|
|
|
-H 'Accept: application/vnd.oci.image.index.v1+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.docker.distribution.manifest.v2+json' \
|
|
|
|
|
"https://forge.lvl0.xyz/v2/lvl0/dishplanner-ci/manifests/${{ steps.meta.outputs.tag }}")"
|
|
|
|
|
if [ "$CODE" = "200" ]; then
|
|
|
|
|
echo "found=true" >> "$GITHUB_OUTPUT"
|
|
|
|
|
else
|
|
|
|
|
echo "found=false" >> "$GITHUB_OUTPUT"
|
|
|
|
|
fi
|
|
|
|
|
|
2026-08-17 23:13:43 +02:00
|
|
|
- name: Build and push CI image
|
2026-08-19 14:33:45 +02:00
|
|
|
if: steps.exists.outputs.found == 'false'
|
2026-08-17 23:13:43 +02:00
|
|
|
uses: https://data.forgejo.org/docker/build-push-action@v5
|
|
|
|
|
with:
|
|
|
|
|
context: .
|
|
|
|
|
file: docker/build/Dockerfile.ci
|
|
|
|
|
push: true
|
|
|
|
|
tags: forge.lvl0.xyz/lvl0/dishplanner-ci:${{ steps.meta.outputs.tag }}
|
2026-08-19 15:49:09 +02:00
|
|
|
secrets: |
|
|
|
|
|
gh_pat=${{ secrets.GH_PAT }}
|
2026-08-17 23:13:43 +02:00
|
|
|
|
2026-08-17 13:30:49 +02:00
|
|
|
ci:
|
2026-08-17 23:13:43 +02:00
|
|
|
needs: ci-image
|
2026-08-17 13:30:49 +02:00
|
|
|
runs-on: docker
|
|
|
|
|
container:
|
2026-08-17 23:13:43 +02:00
|
|
|
image: forge.lvl0.xyz/lvl0/dishplanner-ci:${{ needs.ci-image.outputs.tag }}
|
2026-08-17 13:30:49 +02:00
|
|
|
steps:
|
|
|
|
|
- uses: https://data.forgejo.org/actions/checkout@v4
|
|
|
|
|
|
|
|
|
|
- name: Prepare environment
|
|
|
|
|
run: cp .env.testing .env
|
|
|
|
|
|
2026-08-17 21:18:01 +02:00
|
|
|
- name: Restore dependencies
|
|
|
|
|
run: |
|
|
|
|
|
cp -a /opt/deps/vendor ./vendor
|
2026-08-17 23:13:43 +02:00
|
|
|
composer install --no-interaction --no-progress
|
2026-08-17 21:18:01 +02:00
|
|
|
|
2026-08-17 13:30:49 +02:00
|
|
|
- name: Lint
|
|
|
|
|
run: vendor/bin/pint --test
|
|
|
|
|
|
|
|
|
|
- name: Static analysis
|
|
|
|
|
run: vendor/bin/phpstan analyse --memory-limit=1G
|
|
|
|
|
|
|
|
|
|
- name: Tests
|
2026-08-19 02:09:42 +02:00
|
|
|
run: vendor/bin/pest
|
|
|
|
|
|
2026-08-19 19:32:08 +02:00
|
|
|
- name: Restore frontend dependencies
|
|
|
|
|
run: cp -a /opt/deps-node/node_modules ./node_modules
|
2026-08-19 02:09:42 +02:00
|
|
|
|
|
|
|
|
- name: Build frontend assets
|
|
|
|
|
run: npm run build
|
|
|
|
|
|
|
|
|
|
- name: Browser tests
|
|
|
|
|
run: vendor/bin/pest tests/Browser
|