Adds Gitea Actions CI/CD for test and production
Continuous Integration / check (pull_request) Failing after 6m55s
Continuous Integration / lighthouse (pull_request) Skipped
Continuous Integration / deploy-test (pull_request) Skipped
Continuous Integration / deploy-production (pull_request) Skipped

The pipeline runs lint, format, tests, build, dependency audit and
Lighthouse (mobile and desktop, Playwright Chromium on the arm64 runner)
on every pull request, push to master and manual run.

Pushes to master deploy to test automatically, and any branch can be
deployed to test manually. Test is a Raspberry Pi with nginx next to the
current WordPress site; the deploy refuses folders containing WordPress.
Production deploys are manual and only from release/* branches, over
FTP with TLS to the IIS webhost.

The IIS web.config and both nginx configs are generated from the same
security header list as the Vite servers, with a test that fails when
the generated files drift. Adds .gitattributes for LF line endings and
pins pnpm through packageManager.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-19 00:18:51 +02:00
co-authored by Claude Opus 5.5
parent 069c7cb7eb
commit e6436601a4
20 changed files with 1394 additions and 10 deletions
@@ -0,0 +1,239 @@
name: Continuous Integration
# Branchstrategie (zie aidlc-docs/.../operations/deployment/deployment-plan.md):
# - Pull request → controles, geen deploy
# - Merge/push naar master → controles + automatisch naar test
# - Handmatig, elke branch → controles + naar test als 'Deploy to Test' aan staat
# - Handmatig, release/* → controles + naar productie als 'Deploy to Production' aan staat
on:
workflow_dispatch:
inputs:
deploy_test:
description: 'Deploy to Test'
type: boolean
default: false
deploy_production:
description: 'Deploy to Production (alleen vanaf een release/*-branch)'
type: boolean
default: false
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [master]
# Alleen bij pull requests een verouderde run afbreken; een deploy wordt nooit
# halverwege gestopt.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
NODE_VERSION: '24'
# Vaste Playwright-versie: levert Chromium voor linux-arm64 (er bestaat geen
# officiële Chrome voor ARM64, en Ubuntu's chromium is een snap die niet in
# een container werkt)
PLAYWRIGHT_VERSION: '1.55.0'
defaults:
run:
working-directory: web
jobs:
# lint, opmaak, tests (incl. property-based en axe), build en audit
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
# pnpm-versie komt uit "packageManager" in web/package.json
- uses: pnpm/action-setup@v4
with:
package_json_file: web/package.json
- name: Get pnpm store directory
id: pnpm-store
run: echo "path=$(pnpm store path)" >> "$GITHUB_OUTPUT"
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-${{ hashFiles('web/pnpm-lock.yaml') }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
- name: Format
run: pnpm format:check
# Logt de fast-check-seed; opnieuw afspelen met FC_SEED=<seed> pnpm test
- name: Tests
run: pnpm test
- name: Build
run: pnpm build
- name: Audit (productiepakketten, blokkerend)
run: pnpm audit:deps
- name: Audit (ontwikkeltools, alleen melden)
run: pnpm audit:dev
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: web/dist/
retention-days: 7
# Lighthouse tegen de gebouwde site (mobiel en desktop)
lighthouse:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- uses: pnpm/action-setup@v4
with:
package_json_file: web/package.json
- name: Get pnpm store directory
id: pnpm-store
run: echo "path=$(pnpm store path)" >> "$GITHUB_OUTPUT"
- name: Restore pnpm store
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-${{ hashFiles('web/pnpm-lock.yaml') }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: dist
path: web/dist
- name: Install Chromium
run: |
pnpm dlx playwright@${{ env.PLAYWRIGHT_VERSION }} install --with-deps chromium
CHROME_PATH="$(find "$HOME/.cache/ms-playwright" -path '*chrome-linux*' -name chrome -type f | head -n 1)"
test -x "$CHROME_PATH"
echo "CHROME_PATH=$CHROME_PATH" >> "$GITHUB_ENV"
"$CHROME_PATH" --version
# Als root in een container weigert Chrome te starten zonder --no-sandbox
# (gelezen door lighthouserc.cjs, zie daar waarom niet via LHCI_*)
- name: Lighthouse
env:
LIGHTHOUSE_CHROME_FLAGS: '--no-sandbox --headless=new'
run: pnpm lighthouse
deploy-test:
needs: [check, lighthouse]
if: (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_test == 'true') || (github.event_name == 'push' && github.ref == 'refs/heads/master')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: dist
path: web/dist
# Eenvoudig: de testmap leegmaken en de nieuwe build erin zetten. Oude
# versies worden niet bewaard. Op de Pi draait ook de huidige
# WordPress-site; daarom weigert deze stap een lege variabele, '/', of
# een map waarin WordPress staat.
- name: Upload naar de testserver
env:
# Secrets via env, zodat bash tekens als $ of ` niet nog eens uitlegt
SSHPASS: ${{ secrets.PI_MAIN_PASSWORD }}
SSH_PORT: ${{ secrets.PI_MAIN_PORT }}
SSH_USER: ${{ secrets.PI_MAIN_USERNAME }}
SSH_HOST: ${{ secrets.PI_MAIN_ADDRESS }}
DEPLOY_PATH: ${{ vars.DEPLOY_PATH_TEST }}
run: |
case "$DEPLOY_PATH" in
''|'/'|*' '*) echo "DEPLOY_PATH_TEST ontbreekt of is ongeldig: '$DEPLOY_PATH'"; exit 1 ;;
esac
sudo apt-get update && sudo apt-get install -y sshpass
SSH="sshpass -e ssh -p $SSH_PORT -o StrictHostKeyChecking=accept-new $SSH_USER@$SSH_HOST"
$SSH "set -e
if [ -e '$DEPLOY_PATH/wp-config.php' ] || [ -d '$DEPLOY_PATH/wp-content' ]; then
echo 'Geweigerd: $DEPLOY_PATH bevat WordPress'; exit 1
fi
mkdir -p '$DEPLOY_PATH'
find '$DEPLOY_PATH' -mindepth 1 -delete"
sshpass -e scp -P "$SSH_PORT" -o StrictHostKeyChecking=accept-new -r dist/. "$SSH_USER@$SSH_HOST:$DEPLOY_PATH/"
echo "Gedeployd naar test: ${GITHUB_REF_NAME} (${GITHUB_SHA::7})"
- name: Controle na deploy
env:
HEALTH_URL: ${{ vars.HEALTH_CHECK_URL_TEST }}
run: |
if [ -z "$HEALTH_URL" ]; then echo "Geen HEALTH_CHECK_URL_TEST ingesteld; overgeslagen"; exit 0; fi
curl -fsS -o /dev/null --retry 5 --retry-delay 3 "$HEALTH_URL"
curl -fsSI "$HEALTH_URL" | grep -qi '^content-security-policy:'
echo "Test bereikbaar met security headers"
deploy-production:
needs: [check, lighthouse]
# Alleen handmatig, en alleen vanaf een release-branch
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_production == 'true' && startsWith(github.ref, 'refs/heads/release/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: dist
path: web/dist
- name: IIS-configuratie toevoegen
run: cp deploy/iis/web.config dist/web.config
# FTP met TLS (verplicht) naar de webhoster. Eerst alle bestanden behalve
# index.html, dan index.html, en pas daarna oude bestanden opruimen. Zo
# verwijst een bezoeker nooit naar een bestand dat er nog niet staat.
- name: Upload naar productie (FTPS)
env:
FTP_HOST: ${{ secrets.FTP_HOST }}
FTP_USER: ${{ secrets.FTP_USERNAME }}
LFTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
FTP_DIR: ${{ vars.FTP_REMOTE_DIR || 'wwwroot' }}
run: |
sudo apt-get update && sudo apt-get install -y lftp
lftp --env-password -u "$FTP_USER" "$FTP_HOST" -e "
set ftp:ssl-force true;
set ftp:ssl-protect-data true;
set net:max-retries 3;
mirror --reverse --verbose --exclude-glob index.html dist/ $FTP_DIR/;
put -O $FTP_DIR dist/index.html;
mirror --reverse --delete --verbose dist/ $FTP_DIR/;
quit"
echo "Gedeployd naar productie: ${GITHUB_REF_NAME} (${GITHUB_SHA::7})"
- name: Controle na deploy
env:
HEALTH_URL: ${{ vars.HEALTH_CHECK_URL_PRODUCTION }}
run: |
if [ -z "$HEALTH_URL" ]; then echo "Geen HEALTH_CHECK_URL_PRODUCTION ingesteld; overgeslagen"; exit 0; fi
curl -fsS -o /dev/null --retry 5 --retry-delay 3 "$HEALTH_URL"
curl -fsSI "$HEALTH_URL" | grep -qi '^content-security-policy:'
echo "Productie bereikbaar met security headers"