dishplanner/.forgejo/workflows/ci.yml
myrmidex 7f7a9450bf
All checks were successful
CI / ci-image (push) Successful in 48m48s
CI / ci (push) Successful in 11m52s
61 - Bake node modules and Chromium into the CI image
2026-08-19 19:32:08 +02:00

97 lines
3.1 KiB
YAML

name: CI
on:
push:
branches: ['release/*']
pull_request:
branches: [main, 'release/*']
jobs:
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: |
HASH="$(cat composer.lock package-lock.json | sha256sum | cut -c1-12)"
echo "tag=php8.3-${HASH}" >> "$GITHUB_OUTPUT"
- 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
- name: Build and push CI image
if: steps.exists.outputs.found == 'false'
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 }}
secrets: |
gh_pat=${{ secrets.GH_PAT }}
ci:
needs: ci-image
runs-on: docker
container:
image: forge.lvl0.xyz/lvl0/dishplanner-ci:${{ needs.ci-image.outputs.tag }}
steps:
- uses: https://data.forgejo.org/actions/checkout@v4
- name: Prepare environment
run: cp .env.testing .env
- name: Restore dependencies
run: |
cp -a /opt/deps/vendor ./vendor
composer install --no-interaction --no-progress
- name: Lint
run: vendor/bin/pint --test
- name: Static analysis
run: vendor/bin/phpstan analyse --memory-limit=1G
- name: Tests
run: vendor/bin/pest
- name: Restore frontend dependencies
run: cp -a /opt/deps-node/node_modules ./node_modules
- name: Build frontend assets
run: npm run build
- name: Browser tests
run: vendor/bin/pest tests/Browser