chore: align deployment pipeline with klz-2026 standards
Some checks failed
Build & Deploy Mintel.me / 🔍 Prepare Environment (push) Successful in 9s
Build & Deploy Mintel.me / 🧪 Quality Assurance (push) Failing after 12s
Build & Deploy Mintel.me / 🏗️ Build App (push) Failing after 28s
Build & Deploy Mintel.me / 🚀 Deploy (push) Has been skipped
Build & Deploy Mintel.me / ⚡ PageSpeed (push) Has been skipped
Build & Deploy Mintel.me / 🔔 Notifications (push) Successful in 1s
Some checks failed
Build & Deploy Mintel.me / 🔍 Prepare Environment (push) Successful in 9s
Build & Deploy Mintel.me / 🧪 Quality Assurance (push) Failing after 12s
Build & Deploy Mintel.me / 🏗️ Build App (push) Failing after 28s
Build & Deploy Mintel.me / 🚀 Deploy (push) Has been skipped
Build & Deploy Mintel.me / ⚡ PageSpeed (push) Has been skipped
Build & Deploy Mintel.me / 🔔 Notifications (push) Successful in 1s
- Ported pagespeed-sitemap.ts and integrated @lhci/cli - Enriched deploy.yml with parallel QA, maintenance, and PageSpeed jobs - Refined environment detection (main/beta/rc/prod) - Consolidated workflows and cleaned up package.json
This commit is contained in:
@@ -1,39 +0,0 @@
|
|||||||
name: 🧪 CI (QA)
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
qa:
|
|
||||||
name: 🧪 Quality Assurance
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: catthehacker/ubuntu:act-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 20
|
|
||||||
|
|
||||||
- name: Setup pnpm
|
|
||||||
uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: pnpm install --frozen-lockfile
|
|
||||||
env:
|
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
|
|
||||||
- name: 🧪 Run Checks
|
|
||||||
run: |
|
|
||||||
pnpm lint
|
|
||||||
pnpm build
|
|
||||||
@@ -7,12 +7,20 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
skip_long_checks:
|
||||||
|
description: 'Skip tests? (true/false)'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ (github.ref_type == 'tag' && !contains(github.ref_name, '-')) && 'prod' || (github.ref_type == 'tag' && 'staging' || 'testing') }}
|
group: ${{ github.workflow }}-${{ (github.ref_type == 'tag' && !contains(github.ref_name, '-')) && 'prod' || (github.ref_type == 'tag' && 'staging' || 'testing') }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
|
# JOB 1: Prepare & Determine Environment
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
prepare:
|
prepare:
|
||||||
name: 🔍 Prepare Environment
|
name: 🔍 Prepare Environment
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
@@ -27,6 +35,103 @@ jobs:
|
|||||||
project_name: ${{ steps.determine.outputs.project_name }}
|
project_name: ${{ steps.determine.outputs.project_name }}
|
||||||
is_prod: ${{ steps.determine.outputs.is_prod }}
|
is_prod: ${{ steps.determine.outputs.is_prod }}
|
||||||
gotify_title: ${{ steps.determine.outputs.gotify_title }}
|
gotify_title: ${{ steps.determine.outputs.gotify_title }}
|
||||||
|
gotify_priority: ${{ steps.determine.outputs.gotify_priority }}
|
||||||
|
short_sha: ${{ steps.determine.outputs.short_sha }}
|
||||||
|
commit_msg: ${{ steps.determine.outputs.commit_msg }}
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: 🧹 Maintenance (High Density Cleanup)
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "Purging old build layers and dangling images..."
|
||||||
|
docker image prune -f
|
||||||
|
docker builder prune -f --filter "until=6h"
|
||||||
|
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: 🔍 Environment & Version ermitteln
|
||||||
|
id: determine
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
TAG="${{ github.ref_name }}"
|
||||||
|
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-9)
|
||||||
|
IMAGE_TAG="sha-${SHORT_SHA}"
|
||||||
|
COMMIT_MSG=$(git log -1 --pretty=%s || echo "No commit message available")
|
||||||
|
|
||||||
|
if [[ "${{ github.ref_type }}" == "branch" && "$TAG" == "main" ]]; then
|
||||||
|
TARGET="testing"
|
||||||
|
IMAGE_TAG="main-${SHORT_SHA}"
|
||||||
|
ENV_FILE=".env.testing"
|
||||||
|
TRAEFIK_HOST='`testing.mintel.me`'
|
||||||
|
NEXT_PUBLIC_BASE_URL="https://testing.mintel.me"
|
||||||
|
DIRECTUS_URL="https://cms.testing.mintel.me"
|
||||||
|
DIRECTUS_HOST='`cms.testing.mintel.me`'
|
||||||
|
PROJECT_NAME="mintel-me-testing"
|
||||||
|
IS_PROD="false"
|
||||||
|
GOTIFY_TITLE="🧪 Testing-Deploy"
|
||||||
|
GOTIFY_PRIORITY=4
|
||||||
|
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
|
||||||
|
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
TARGET="production"
|
||||||
|
IMAGE_TAG="$TAG"
|
||||||
|
ENV_FILE=".env.prod"
|
||||||
|
TRAEFIK_HOST='`mintel.me`, `www.mintel.me`'
|
||||||
|
NEXT_PUBLIC_BASE_URL="https://mintel.me"
|
||||||
|
DIRECTUS_URL="https://cms.mintel.me"
|
||||||
|
DIRECTUS_HOST='`cms.mintel.me`'
|
||||||
|
PROJECT_NAME="mintel-me-prod"
|
||||||
|
IS_PROD="true"
|
||||||
|
GOTIFY_TITLE="🚀 Production-Release"
|
||||||
|
GOTIFY_PRIORITY=6
|
||||||
|
elif [[ "$TAG" =~ -rc || "$TAG" =~ -beta || "$TAG" =~ -alpha ]]; then
|
||||||
|
TARGET="staging"
|
||||||
|
IMAGE_TAG="$TAG"
|
||||||
|
ENV_FILE=".env.staging"
|
||||||
|
TRAEFIK_HOST='`staging.mintel.me`'
|
||||||
|
NEXT_PUBLIC_BASE_URL="https://staging.mintel.me"
|
||||||
|
DIRECTUS_URL="https://cms.staging.mintel.me"
|
||||||
|
DIRECTUS_HOST='`cms.staging.mintel.me`'
|
||||||
|
PROJECT_NAME="mintel-me-staging"
|
||||||
|
IS_PROD="false"
|
||||||
|
GOTIFY_TITLE="🧪 Staging-Deploy (Pre-Release)"
|
||||||
|
GOTIFY_PRIORITY=5
|
||||||
|
else
|
||||||
|
TARGET="skip"
|
||||||
|
GOTIFY_TITLE="❓ Unbekannter Tag"
|
||||||
|
GOTIFY_PRIORITY=3
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
TARGET="skip"
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "target=$TARGET"
|
||||||
|
echo "image_tag=$IMAGE_TAG"
|
||||||
|
echo "env_file=$ENV_FILE"
|
||||||
|
echo "traefik_host=$TRAEFIK_HOST"
|
||||||
|
echo "next_public_base_url=$NEXT_PUBLIC_BASE_URL"
|
||||||
|
echo "directus_url=$DIRECTUS_URL"
|
||||||
|
echo "directus_host=$DIRECTUS_HOST"
|
||||||
|
echo "project_name=$PROJECT_NAME"
|
||||||
|
echo "is_prod=$IS_PROD"
|
||||||
|
echo "gotify_title=$GOTIFY_TITLE"
|
||||||
|
echo "gotify_priority=$GOTIFY_PRIORITY"
|
||||||
|
echo "short_sha=$SHORT_SHA"
|
||||||
|
echo "commit_msg=$COMMIT_MSG"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
|
# JOB 2: Quality Assurance (pnpm Lint & Test)
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
|
qa:
|
||||||
|
name: 🧪 Quality Assurance
|
||||||
|
needs: prepare
|
||||||
|
if: needs.prepare.outputs.target != 'skip'
|
||||||
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -35,73 +140,50 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: 🔍 Determine Environment
|
- name: Setup pnpm
|
||||||
id: determine
|
uses: pnpm/action-setup@v4
|
||||||
shell: bash
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install --frozen-lockfile
|
||||||
|
env:
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
- name: 🧪 Run Checks in Parallel
|
||||||
|
if: github.event.inputs.skip_long_checks != 'true'
|
||||||
run: |
|
run: |
|
||||||
TAG="${{ github.ref_name }}"
|
pnpm lint &
|
||||||
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-9)
|
LINT_PID=$!
|
||||||
|
pnpm --filter @mintel/web typecheck &
|
||||||
if [[ "${{ github.ref_type }}" == "branch" && "$TAG" == "main" ]]; then
|
TYPE_PID=$!
|
||||||
TARGET="testing"
|
# pnpm test &
|
||||||
IMAGE_TAG="main-${SHORT_SHA}"
|
# TEST_PID=$!
|
||||||
ENV_FILE=".env.testing"
|
|
||||||
TRAEFIK_HOST="testing.mintel.me"
|
|
||||||
NEXT_PUBLIC_BASE_URL="https://testing.mintel.me"
|
|
||||||
DIRECTUS_URL="https://cms.testing.mintel.me"
|
|
||||||
DIRECTUS_HOST="cms.testing.mintel.me"
|
|
||||||
PROJECT_NAME="mintel-me-testing"
|
|
||||||
IS_PROD="false"
|
|
||||||
GOTIFY_TITLE="🧪 Testing-Deploy"
|
|
||||||
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
|
|
||||||
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
||||||
TARGET="production"
|
|
||||||
IMAGE_TAG="$TAG"
|
|
||||||
ENV_FILE=".env.prod"
|
|
||||||
TRAEFIK_HOST="mintel.me, www.mintel.me"
|
|
||||||
NEXT_PUBLIC_BASE_URL="https://mintel.me"
|
|
||||||
DIRECTUS_URL="https://cms.mintel.me"
|
|
||||||
DIRECTUS_HOST="cms.mintel.me"
|
|
||||||
PROJECT_NAME="mintel-me-prod"
|
|
||||||
IS_PROD="true"
|
|
||||||
GOTIFY_TITLE="🚀 Production-Release"
|
|
||||||
else
|
|
||||||
TARGET="staging"
|
|
||||||
IMAGE_TAG="$TAG"
|
|
||||||
ENV_FILE=".env.staging"
|
|
||||||
TRAEFIK_HOST="staging.mintel.me"
|
|
||||||
NEXT_PUBLIC_BASE_URL="https://staging.mintel.me"
|
|
||||||
DIRECTUS_URL="https://cms.staging.mintel.me"
|
|
||||||
DIRECTUS_HOST="cms.staging.mintel.me"
|
|
||||||
PROJECT_NAME="mintel-me-staging"
|
|
||||||
IS_PROD="false"
|
|
||||||
GOTIFY_TITLE="🧪 Staging-Deploy"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Skipping deploy for unknown ref type"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "target=$TARGET" >> $GITHUB_OUTPUT
|
wait $LINT_PID || exit 1
|
||||||
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
|
wait $TYPE_PID || exit 1
|
||||||
echo "env_file=$ENV_FILE" >> $GITHUB_OUTPUT
|
# wait $TEST_PID || exit 1
|
||||||
echo "traefik_host=$TRAEFIK_HOST" >> $GITHUB_OUTPUT
|
|
||||||
echo "next_public_base_url=$NEXT_PUBLIC_BASE_URL" >> $GITHUB_OUTPUT
|
|
||||||
echo "directus_url=$DIRECTUS_URL" >> $GITHUB_OUTPUT
|
|
||||||
echo "directus_host=$DIRECTUS_HOST" >> $GITHUB_OUTPUT
|
|
||||||
echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT
|
|
||||||
echo "is_prod=$IS_PROD" >> $GITHUB_OUTPUT
|
|
||||||
echo "gotify_title=$GOTIFY_TITLE" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
|
# JOB 3: Build & Push Docker Image
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
build:
|
build:
|
||||||
name: 🏗️ Build & Push
|
name: 🏗️ Build App
|
||||||
needs: prepare
|
needs: prepare
|
||||||
|
if: ${{ needs.prepare.outputs.target != 'skip' }}
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: 🐳 Set up Docker Buildx
|
- name: 🐳 Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -110,12 +192,13 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||||
|
|
||||||
- name: 🏗️ Build & Push
|
- name: 🏗️ App bauen & pushen
|
||||||
env:
|
env:
|
||||||
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
||||||
TARGET: ${{ needs.prepare.outputs.target }}
|
TARGET: ${{ needs.prepare.outputs.target }}
|
||||||
NEXT_PUBLIC_BASE_URL: ${{ needs.prepare.outputs.next_public_base_url }}
|
NEXT_PUBLIC_BASE_URL: ${{ needs.prepare.outputs.next_public_base_url }}
|
||||||
DIRECTUS_URL: ${{ needs.prepare.outputs.directus_url }}
|
DIRECTUS_URL: ${{ needs.prepare.outputs.directus_url }}
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--pull \
|
--pull \
|
||||||
@@ -125,27 +208,33 @@ jobs:
|
|||||||
--build-arg DIRECTUS_URL="$DIRECTUS_URL" \
|
--build-arg DIRECTUS_URL="$DIRECTUS_URL" \
|
||||||
--secret id=NPM_TOKEN,env=NPM_TOKEN \
|
--secret id=NPM_TOKEN,env=NPM_TOKEN \
|
||||||
-t registry.infra.mintel.me/mintel/mintel.me:$IMAGE_TAG \
|
-t registry.infra.mintel.me/mintel/mintel.me:$IMAGE_TAG \
|
||||||
|
--cache-from type=registry,ref=registry.infra.mintel.me/mintel/mintel.me:buildcache \
|
||||||
|
--cache-to type=registry,ref=registry.infra.mintel.me/mintel/mintel.me:buildcache,mode=max \
|
||||||
--push .
|
--push .
|
||||||
env:
|
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
|
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
|
# JOB 4: Deploy via SSH
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
deploy:
|
deploy:
|
||||||
name: 🚀 Deploy
|
name: 🚀 Deploy
|
||||||
needs: [prepare, build]
|
needs: [prepare, build, qa]
|
||||||
|
if: ${{ needs.prepare.outputs.target != 'skip' }}
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
env:
|
||||||
|
TARGET: ${{ needs.prepare.outputs.target }}
|
||||||
|
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
||||||
|
ENV_FILE: ${{ needs.prepare.outputs.env_file }}
|
||||||
|
PROJECT_NAME: ${{ needs.prepare.outputs.project_name }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: 🚀 Deploy via SSH
|
- name: 🚀 Deploy via SSH
|
||||||
env:
|
shell: bash
|
||||||
TARGET: ${{ needs.prepare.outputs.target }}
|
|
||||||
IMAGE_TAG: ${{ needs.prepare.outputs.image_tag }}
|
|
||||||
ENV_FILE: ${{ needs.prepare.outputs.env_file }}
|
|
||||||
PROJECT_NAME: ${{ needs.prepare.outputs.project_name }}
|
|
||||||
AUTH_MIDDLEWARE: ${{ needs.prepare.outputs.is_prod == 'true' && 'compress' || format('{0}-auth,compress', needs.prepare.outputs.project_name) }}
|
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.ALPHA_SSH_KEY }}" > ~/.ssh/id_ed25519
|
echo "${{ secrets.ALPHA_SSH_KEY }}" > ~/.ssh/id_ed25519
|
||||||
@@ -153,8 +242,8 @@ jobs:
|
|||||||
ssh-keyscan -H alpha.mintel.me >> ~/.ssh/known_hosts 2>/dev/null
|
ssh-keyscan -H alpha.mintel.me >> ~/.ssh/known_hosts 2>/dev/null
|
||||||
|
|
||||||
# Create .env on the fly
|
# Create .env on the fly
|
||||||
cat > .env.tmp << EOF
|
cat > /tmp/mintel.me.env << EOF
|
||||||
# Generated by CI
|
# Generated by CI - $TARGET - $(date -u)
|
||||||
NEXT_PUBLIC_BASE_URL=${{ needs.prepare.outputs.next_public_base_url }}
|
NEXT_PUBLIC_BASE_URL=${{ needs.prepare.outputs.next_public_base_url }}
|
||||||
NEXT_PUBLIC_TARGET=$TARGET
|
NEXT_PUBLIC_TARGET=$TARGET
|
||||||
DIRECTUS_URL=${{ needs.prepare.outputs.directus_url }}
|
DIRECTUS_URL=${{ needs.prepare.outputs.directus_url }}
|
||||||
@@ -162,7 +251,7 @@ jobs:
|
|||||||
TRAEFIK_HOST=${{ needs.prepare.outputs.traefik_host }}
|
TRAEFIK_HOST=${{ needs.prepare.outputs.traefik_host }}
|
||||||
IMAGE_TAG=$IMAGE_TAG
|
IMAGE_TAG=$IMAGE_TAG
|
||||||
PROJECT_NAME=$PROJECT_NAME
|
PROJECT_NAME=$PROJECT_NAME
|
||||||
AUTH_MIDDLEWARE=$AUTH_MIDDLEWARE
|
AUTH_MIDDLEWARE=$( [[ "$TARGET" == "production" ]] && echo "compress" || echo "${PROJECT_NAME}-auth,compress" )
|
||||||
|
|
||||||
# Secrets
|
# Secrets
|
||||||
DIRECTUS_KEY=${{ secrets.DIRECTUS_KEY }}
|
DIRECTUS_KEY=${{ secrets.DIRECTUS_KEY }}
|
||||||
@@ -170,23 +259,106 @@ jobs:
|
|||||||
DIRECTUS_DB_NAME=${{ secrets.DIRECTUS_DB_NAME || 'directus' }}
|
DIRECTUS_DB_NAME=${{ secrets.DIRECTUS_DB_NAME || 'directus' }}
|
||||||
DIRECTUS_DB_USER=${{ secrets.DIRECTUS_DB_USER || 'directus' }}
|
DIRECTUS_DB_USER=${{ secrets.DIRECTUS_DB_USER || 'directus' }}
|
||||||
DIRECTUS_DB_PASSWORD=${{ secrets.DIRECTUS_DB_PASSWORD }}
|
DIRECTUS_DB_PASSWORD=${{ secrets.DIRECTUS_DB_PASSWORD }}
|
||||||
|
|
||||||
|
# General
|
||||||
|
NODE_ENV=production
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
scp .env.tmp root@alpha.mintel.me:/home/deploy/sites/mintel.me/$ENV_FILE
|
# 1. Cleanup and Create Directories on server BEFORE SCP
|
||||||
|
ssh -o StrictHostKeyChecking=accept-new root@alpha.mintel.me bash << 'EOF'
|
||||||
|
set -e
|
||||||
|
mkdir -p /home/deploy/sites/mintel.me/varnish
|
||||||
|
mkdir -p /home/deploy/sites/mintel.me/directus/uploads /home/deploy/sites/mintel.me/directus/extensions
|
||||||
|
if [ -d "/home/deploy/sites/mintel.me/varnish/default.vcl" ]; then
|
||||||
|
echo "🧹 Removing directory 'varnish/default.vcl' created by Docker..."
|
||||||
|
rm -rf /home/deploy/sites/mintel.me/varnish/default.vcl
|
||||||
|
fi
|
||||||
|
chown -R deploy:deploy /home/deploy/sites/mintel.me/directus /home/deploy/sites/mintel.me/varnish
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# 2. Transfer files
|
||||||
|
scp /tmp/mintel.me.env root@alpha.mintel.me:/home/deploy/sites/mintel.me/$ENV_FILE
|
||||||
scp docker-compose.yml root@alpha.mintel.me:/home/deploy/sites/mintel.me/docker-compose.yml
|
scp docker-compose.yml root@alpha.mintel.me:/home/deploy/sites/mintel.me/docker-compose.yml
|
||||||
scp -r varnish root@alpha.mintel.me:/home/deploy/sites/mintel.me/
|
scp -r varnish root@alpha.mintel.me:/home/deploy/sites/mintel.me/
|
||||||
|
|
||||||
ssh root@alpha.mintel.me IMAGE_TAG="$IMAGE_TAG" ENV_FILE="$ENV_FILE" PROJECT_NAME="$PROJECT_NAME" bash << 'EOF'
|
ssh root@alpha.mintel.me IMAGE_TAG="$IMAGE_TAG" ENV_FILE="$ENV_FILE" PROJECT_NAME="$PROJECT_NAME" bash << 'EOF'
|
||||||
|
set -e
|
||||||
cd /home/deploy/sites/mintel.me
|
cd /home/deploy/sites/mintel.me
|
||||||
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
echo "${{ secrets.REGISTRY_PASS }}" | docker login registry.infra.mintel.me -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||||
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" pull
|
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" pull
|
||||||
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" up -d --remove-orphans
|
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" up -d --remove-orphans
|
||||||
docker system prune -f --filter "until=24h"
|
docker system prune -f --filter "until=24h"
|
||||||
|
echo "→ Waiting 15s for warmup..."
|
||||||
|
sleep 15
|
||||||
|
docker compose -p "$PROJECT_NAME" --env-file "$ENV_FILE" ps
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
|
# JOB 5: PageSpeed Test
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
|
pagespeed:
|
||||||
|
name: ⚡ PageSpeed
|
||||||
|
needs: [prepare, deploy]
|
||||||
|
if: |
|
||||||
|
always() &&
|
||||||
|
needs.prepare.outputs.target != 'skip' &&
|
||||||
|
needs.deploy.result == 'success' &&
|
||||||
|
github.event.inputs.skip_long_checks != 'true'
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install --frozen-lockfile
|
||||||
|
env:
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
- name: 🔍 Install Chromium (ARM64)
|
||||||
|
run: |
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y gnupg wget ca-certificates
|
||||||
|
CODENAME=$(. /etc/os-release && echo $VERSION_CODENAME)
|
||||||
|
|
||||||
|
mkdir -p /etc/apt/keyrings
|
||||||
|
KEY_ID="82BB6851C64F6880"
|
||||||
|
wget -qO- "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x$KEY_ID" | gpg --dearmor > /etc/apt/keyrings/xtradeb.gpg
|
||||||
|
echo "deb [signed-by=/etc/apt/keyrings/xtradeb.gpg] http://ppa.launchpad.net/xtradeb/apps/ubuntu $CODENAME main" > /etc/apt/sources.list.d/xtradeb-ppa.list
|
||||||
|
printf "Package: *\nPin: release o=LP-PPA-xtradeb-apps\nPin-Priority: 1001\n" > /etc/apt/preferences.d/xtradeb
|
||||||
|
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --allow-downgrades chromium
|
||||||
|
[ -f /usr/bin/chromium ] && ln -sf /usr/bin/chromium /usr/bin/google-chrome
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: 🧪 Run PageSpeed (Lighthouse)
|
||||||
|
env:
|
||||||
|
NEXT_PUBLIC_BASE_URL: ${{ needs.prepare.outputs.next_public_base_url }}
|
||||||
|
GATEKEEPER_PASSWORD: ${{ secrets.GATEKEEPER_PASSWORD || 'klz2026' }}
|
||||||
|
PAGESPEED_LIMIT: 8
|
||||||
|
CHROME_PATH: /usr/bin/chromium
|
||||||
|
run: pnpm --filter @mintel/web run pagespeed:test
|
||||||
|
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
|
# JOB 6: Notifications
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────────
|
||||||
notifications:
|
notifications:
|
||||||
name: 🔔 Notifications
|
name: 🔔 Notifications
|
||||||
needs: [prepare, deploy]
|
needs: [prepare, qa, build, deploy, pagespeed]
|
||||||
if: always()
|
if: always()
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
@@ -195,7 +367,8 @@ jobs:
|
|||||||
- name: 🔔 Gotify
|
- name: 🔔 Gotify
|
||||||
run: |
|
run: |
|
||||||
STATUS="${{ needs.deploy.result == 'success' && '✅' || '❌' }}"
|
STATUS="${{ needs.deploy.result == 'success' && '✅' || '❌' }}"
|
||||||
|
PRIORITY="${{ needs.deploy.result == 'success' && needs.prepare.outputs.gotify_priority || '8' }}"
|
||||||
curl -s -k -X POST "${{ secrets.GOTIFY_URL }}/message?token=${{ secrets.GOTIFY_TOKEN }}" \
|
curl -s -k -X POST "${{ secrets.GOTIFY_URL }}/message?token=${{ secrets.GOTIFY_TOKEN }}" \
|
||||||
-F "title=$STATUS ${{ needs.prepare.outputs.gotify_title }}" \
|
-F "title=$STATUS ${{ needs.prepare.outputs.gotify_title }}" \
|
||||||
-F "message=Deploy to **${{ needs.prepare.outputs.target }}** ${{ needs.deploy.result }}.\nVersion: ${{ needs.prepare.outputs.image_tag }}" \
|
-F "message=Deploy to **${{ needs.prepare.outputs.target }}** ${{ needs.deploy.result }}.\n\nVersion: **${{ needs.prepare.outputs.image_tag }}**\nCommit: ${{ needs.prepare.outputs.short_sha }} (${{ needs.prepare.outputs.commit_msg }})\nActor: ${{ github.actor }}" \
|
||||||
-F "priority=5" || true
|
-F "priority=$PRIORITY" || true
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
"test": "npm run test:smoke",
|
"test": "npm run test:links",
|
||||||
"test:smoke": "tsx ./scripts/smoke-test.ts",
|
|
||||||
"test:links": "tsx ./scripts/test-links.ts",
|
"test:links": "tsx ./scripts/test-links.ts",
|
||||||
"test:file-examples": "tsx ./scripts/test-file-examples-comprehensive.ts",
|
"test:file-examples": "tsx ./scripts/test-file-examples-comprehensive.ts",
|
||||||
"clone-website": "tsx ./scripts/clone-recursive.ts",
|
"clone-website": "tsx ./scripts/clone-recursive.ts",
|
||||||
@@ -20,7 +19,9 @@
|
|||||||
"video:render": "remotion render video/index.ts ButtonShowcase out/button-showcase.mp4",
|
"video:render": "remotion render video/index.ts ButtonShowcase out/button-showcase.mp4",
|
||||||
"video:render:contact": "remotion render video/index.ts ContactFormShowcase out/contact-showcase.mp4 --concurrency=1 --codec=h264 --crf=16 --pixel-format=yuv420p --overwrite",
|
"video:render:contact": "remotion render video/index.ts ContactFormShowcase out/contact-showcase.mp4 --concurrency=1 --codec=h264 --crf=16 --pixel-format=yuv420p --overwrite",
|
||||||
"video:render:button": "remotion render video/index.ts ButtonShowcase out/button-showcase.mp4 --concurrency=1 --codec=h264 --crf=16 --pixel-format=yuv420p --overwrite",
|
"video:render:button": "remotion render video/index.ts ButtonShowcase out/button-showcase.mp4 --concurrency=1 --codec=h264 --crf=16 --pixel-format=yuv420p --overwrite",
|
||||||
"video:render:all": "npm run video:render:contact && npm run video:render:button"
|
"video:render:all": "npm run video:render:contact && npm run video:render:button",
|
||||||
|
"pagespeed:test": "tsx ./scripts/pagespeed-sitemap.ts",
|
||||||
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mintel/next-utils": "^1.0.1",
|
"@mintel/next-utils": "^1.0.1",
|
||||||
@@ -67,6 +68,8 @@
|
|||||||
"@types/qrcode": "^1.5.6",
|
"@types/qrcode": "^1.5.6",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"postcss": "^8.4.49",
|
"postcss": "^8.4.49",
|
||||||
|
"@lhci/cli": "^0.15.1",
|
||||||
|
"cheerio": "^1.1.2",
|
||||||
"tsx": "^4.21.0",
|
"tsx": "^4.21.0",
|
||||||
"typescript": "5.9.3"
|
"typescript": "5.9.3"
|
||||||
}
|
}
|
||||||
|
|||||||
159
apps/web/scripts/pagespeed-sitemap.ts
Normal file
159
apps/web/scripts/pagespeed-sitemap.ts
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import * as cheerio from 'cheerio';
|
||||||
|
import { execSync } from 'child_process';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PageSpeed Test Script
|
||||||
|
*
|
||||||
|
* 1. Fetches sitemap.xml from the target URL
|
||||||
|
* 2. Extracts all URLs
|
||||||
|
* 3. Runs Lighthouse CI on those URLs
|
||||||
|
*/
|
||||||
|
|
||||||
|
const targetUrl =
|
||||||
|
process.argv[2] || process.env.NEXT_PUBLIC_BASE_URL || 'https://testing.klz-cables.com';
|
||||||
|
const limit = process.env.PAGESPEED_LIMIT ? parseInt(process.env.PAGESPEED_LIMIT) : 20; // Default limit to avoid infinite runs
|
||||||
|
const gatekeeperPassword = process.env.GATEKEEPER_PASSWORD || 'klz2026';
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
console.log(`\n🚀 Starting PageSpeed test for: ${targetUrl}`);
|
||||||
|
console.log(`📊 Limit: ${limit} pages\n`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. Fetch Sitemap
|
||||||
|
const sitemapUrl = `${targetUrl.replace(/\/$/, '')}/sitemap.xml`;
|
||||||
|
console.log(`📥 Fetching sitemap from ${sitemapUrl}...`);
|
||||||
|
|
||||||
|
// We might need to bypass gatekeeper for the sitemap fetch too
|
||||||
|
const response = await axios.get(sitemapUrl, {
|
||||||
|
headers: {
|
||||||
|
Cookie: `klz_gatekeeper_session=${gatekeeperPassword}`,
|
||||||
|
},
|
||||||
|
validateStatus: (status) => status < 400,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data, { xmlMode: true });
|
||||||
|
let urls = $('url loc')
|
||||||
|
.map((i, el) => $(el).text())
|
||||||
|
.get();
|
||||||
|
|
||||||
|
// Cleanup, filter and normalize domains to targetUrl
|
||||||
|
const urlPattern = /https?:\/\/[^\/]+/;
|
||||||
|
urls = [...new Set(urls)]
|
||||||
|
.filter((u) => u.startsWith('http'))
|
||||||
|
.map((u) => u.replace(urlPattern, targetUrl.replace(/\/$/, '')))
|
||||||
|
.sort();
|
||||||
|
|
||||||
|
console.log(`✅ Found ${urls.length} URLs in sitemap.`);
|
||||||
|
|
||||||
|
if (urls.length === 0) {
|
||||||
|
console.error('❌ No URLs found in sitemap. Is the site up?');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (urls.length > limit) {
|
||||||
|
console.log(
|
||||||
|
`⚠️ Too many pages (${urls.length}). Limiting to ${limit} representative pages.`,
|
||||||
|
);
|
||||||
|
// Try to pick a variety: home, some products, some blog posts
|
||||||
|
const home = urls.filter((u) => u.endsWith('/de') || u.endsWith('/en') || u === targetUrl);
|
||||||
|
const others = urls.filter((u) => !home.includes(u));
|
||||||
|
urls = [...home, ...others.slice(0, limit - home.length)];
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`🧪 Pages to be tested:`);
|
||||||
|
urls.forEach((u) => console.log(` - ${u}`));
|
||||||
|
|
||||||
|
// 2. Prepare LHCI command
|
||||||
|
// We use --collect.url multiple times
|
||||||
|
const urlArgs = urls.map((u) => `--collect.url="${u}"`).join(' ');
|
||||||
|
|
||||||
|
// Handle authentication for staging/testing
|
||||||
|
// Lighthouse can set cookies via --collect.settings.extraHeaders
|
||||||
|
const extraHeaders = JSON.stringify({
|
||||||
|
Cookie: `klz_gatekeeper_session=${gatekeeperPassword}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
const chromePath = process.env.CHROME_PATH || process.env.PUPPETEER_EXECUTABLE_PATH;
|
||||||
|
const chromePathArg = chromePath ? `--collect.chromePath="${chromePath}"` : '';
|
||||||
|
|
||||||
|
// Clean up old reports
|
||||||
|
if (fs.existsSync('.lighthouseci')) {
|
||||||
|
fs.rmSync('.lighthouseci', { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Using a more robust way to execute and capture output
|
||||||
|
// We remove 'npx lhci upload' to keep everything local and avoid Google-hosted reports
|
||||||
|
const lhciCommand = `npx lhci collect ${urlArgs} ${chromePathArg} --collect.settings.chromeFlags='--no-sandbox --disable-setuid-sandbox' --collect.settings.extraHeaders='${extraHeaders}' && npx lhci assert`;
|
||||||
|
|
||||||
|
console.log(`💻 Executing LHCI...`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
execSync(lhciCommand, {
|
||||||
|
encoding: 'utf8',
|
||||||
|
stdio: 'inherit',
|
||||||
|
});
|
||||||
|
} catch (err: any) {
|
||||||
|
console.warn('⚠️ LHCI assertion finished with warnings or errors.');
|
||||||
|
// We continue to show the table even if assertions failed
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Summarize Results (Local & Independent)
|
||||||
|
const manifestPath = path.join(process.cwd(), '.lighthouseci', 'manifest.json');
|
||||||
|
if (fs.existsSync(manifestPath)) {
|
||||||
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
||||||
|
console.log(`\n📊 PageSpeed Summary (FOSS - Local Report):\n`);
|
||||||
|
|
||||||
|
const summaryTable = manifest.map((entry: any) => {
|
||||||
|
const s = entry.summary;
|
||||||
|
return {
|
||||||
|
URL: entry.url.replace(targetUrl, ''),
|
||||||
|
Perf: Math.round(s.performance * 100),
|
||||||
|
Acc: Math.round(s.accessibility * 100),
|
||||||
|
BP: Math.round(s['best-practices'] * 100),
|
||||||
|
SEO: Math.round(s.seo * 100),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
console.table(summaryTable);
|
||||||
|
|
||||||
|
// Calculate Average
|
||||||
|
const avg = {
|
||||||
|
Perf: Math.round(
|
||||||
|
summaryTable.reduce((acc: any, curr: any) => acc + curr.Perf, 0) / summaryTable.length,
|
||||||
|
),
|
||||||
|
Acc: Math.round(
|
||||||
|
summaryTable.reduce((acc: any, curr: any) => acc + curr.Acc, 0) / summaryTable.length,
|
||||||
|
),
|
||||||
|
BP: Math.round(
|
||||||
|
summaryTable.reduce((acc: any, curr: any) => acc + curr.BP, 0) / summaryTable.length,
|
||||||
|
),
|
||||||
|
SEO: Math.round(
|
||||||
|
summaryTable.reduce((acc: any, curr: any) => acc + curr.SEO, 0) / summaryTable.length,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(`\n📈 Average Scores:`);
|
||||||
|
console.log(` Performance: ${avg.Perf > 90 ? '✅' : '⚠️'} ${avg.Perf}`);
|
||||||
|
console.log(` Accessibility: ${avg.Acc > 90 ? '✅' : '⚠️'} ${avg.Acc}`);
|
||||||
|
console.log(` Best Practices: ${avg.BP > 90 ? '✅' : '⚠️'} ${avg.BP}`);
|
||||||
|
console.log(` SEO: ${avg.SEO > 90 ? '✅' : '⚠️'} ${avg.SEO}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\n✨ PageSpeed tests completed successfully!`);
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error(`\n❌ Error during PageSpeed test:`);
|
||||||
|
if (axios.isAxiosError(error)) {
|
||||||
|
console.error(`Status: ${error.response?.status}`);
|
||||||
|
console.error(`StatusText: ${error.response?.statusText}`);
|
||||||
|
console.error(`URL: ${error.config?.url}`);
|
||||||
|
} else {
|
||||||
|
console.error(error.message);
|
||||||
|
}
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
Reference in New Issue
Block a user