Files
playground-frontend/.gitea/workflows/build-Frontend-a.yml
Andreas Dahm 1087fc40e0
All checks were successful
Build, Test & Push Frontend / quality-check (pull_request) Successful in 1m45s
Build, Test & Push Frontend / docker (pull_request) Has been skipped
Try to fix test
2026-06-02 15:56:15 +02:00

127 lines
3.9 KiB
YAML

name: Build, Test & Push Frontend
run-name: ${{ gitea.actor }} build and test Angular 🚀
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
# ------------------------------------------------------------------
# JOB 1: Code integrity and quality gates (CI)
# ------------------------------------------------------------------
quality-check:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install Linux Libs
run: |
sudo apt-get update
sudo apt-get install -y \
libnss3 \
libnspr4 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2t64 \
libdrm2 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libasound2t64 \
libpango-1.0-0 \
libcairo2
- name: Install Dependencies
run: npm ci
# 1. Linting (Code-Style)
- name: Lint & Type Check
run: npm run lint --if-present
# 2. i18n key sync (en/de must share the same keys)
- name: i18n Key Check
run: npm run i18n:check
# 3. Unit Tests (Logic) — browser/launcher configured in karma.conf.js
- name: Unit Tests
run: npx ng test --watch=false
# 4. Build Production (necessary for lighthouse)
- name: Build Production
run: npx ng build --configuration production
# 5. Lighthouse Audit (Performance & SEO)
# Puppeteer is a devDependency, so `npm ci` already installed it and
# downloaded Chrome. executablePath() is async in Puppeteer v25, so await it.
- name: Lighthouse CI
run: |
CHROME_PATH=$(node -e 'require("puppeteer").executablePath().then(p => console.log(p))')
export CHROME_PATH=$CHROME_PATH
npx lhci autorun
# ------------------------------------------------------------------
# JOB 2: Docker Build & Push (CD)
# Runs only if 'quality-check' are successfully and we are on branch main.
# ------------------------------------------------------------------
docker:
needs: quality-check
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Prepare tag (sanitize branch)
id: prep
shell: bash
run: |
BRANCH="${GITHUB_REF_NAME}"
BRANCH="${BRANCH//\//-}"
BRANCH="$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]')"
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
echo "sha=${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
# Convert repository owner to lowercase
OWNER="${GITHUB_REPOSITORY_OWNER}"
OWNER="$(echo "$OWNER" | tr '[:upper:]' '[:lower:]')"
echo "owner=$OWNER" >> "$GITHUB_OUTPUT"
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: git.andreas-dahm.eu
username: ${{ github.repository_owner }}
password: ${{ secrets.TOKEN_GITEA }}
- name: Build & Push (branch + sha tags)
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
git.andreas-dahm.eu/${{ steps.prep.outputs.owner }}/playground:frontend-a-${{ steps.prep.outputs.branch }}
git.andreas-dahm.eu/${{ steps.prep.outputs.owner }}/playground:frontend-a-${{ steps.prep.outputs.branch }}-${{ steps.prep.outputs.sha }}
- name: Also push moving main tag
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
git.andreas-dahm.eu/${{ steps.prep.outputs.owner }}/playground:frontend-a-main