### Summary of Changes - **Version Metadata Generation**: - `ci/docker/www/Dockerfile` & `ci/docker/docs/Dockerfile` accept `COMMIT_SHA` and `VERSION` build args and write `/usr/share/nginx/html/version.json`. - `ci/config/nginx/default.conf` configures `location = /version.json` with `Cache-Control: no-store, no-cache, must-revalidate` so verification is never stale. - **Automated Rollout Verification**: - `.github/workflows/services-www-releases-dispatch-release.yml` - `.github/workflows/services-docs-next-required.yml` - `.github/workflows/services-www-next-required.yml` - Added `verify-rollout` job that polls `https://www.ermnvldmr.com/version.json` and `https://docs.ermnvldmr.com/version.json` with 10s intervals (up to 5 minutes) to ensure the commit actively rolls out to users.
439 lines
13 KiB
YAML
439 lines
13 KiB
YAML
name: services/www - next/required
|
|
|
|
on:
|
|
push:
|
|
branches: [next]
|
|
paths:
|
|
- 'services/www/**'
|
|
- 'packages/ui/**'
|
|
- 'packages/stl/**'
|
|
- 'packages/i18n/**'
|
|
- '.github/workflows/services-www-next-required.yml'
|
|
- 'pnpm-lock.yaml'
|
|
|
|
concurrency:
|
|
group: ci-www-${{ github.ref_name }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
actions: read
|
|
|
|
jobs:
|
|
setup-stage:
|
|
name: Setup - Stage
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
cache-hit: ${{ steps.cache-pnpm-store.outputs.cache-hit }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9.12.3
|
|
|
|
- name: Setup Node.js with pnpm cache
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'pnpm'
|
|
|
|
- name: Cache pnpm store
|
|
id: cache-pnpm-store
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.pnpm-store
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
build-configs:
|
|
name: Build - Configs
|
|
needs: setup-stage
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9.12.3
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'pnpm'
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Build Rsbuild config
|
|
run: pnpm --filter @ermnvldmr/rsbuild-config build
|
|
- name: Build Storybook config
|
|
run: pnpm --filter @ermnvldmr/storybook-config build
|
|
- name: Upload Rsbuild Config
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: rsbuild-config-dist
|
|
path: packages/rsbuild-config/dist
|
|
retention-days: 1
|
|
- name: Upload Storybook Config
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: storybook-config-dist
|
|
path: packages/storybook-config/dist
|
|
retention-days: 1
|
|
- name: Build i18n package
|
|
run: pnpm --filter @ermnvldmr/i18n build
|
|
- name: Upload i18n dist
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: i18n-dist
|
|
path: packages/i18n/dist
|
|
retention-days: 1
|
|
|
|
lint-www:
|
|
name: Lint - WWW
|
|
needs: build-configs
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9.12.3
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'pnpm'
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Download Rsbuild Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: rsbuild-config-dist
|
|
path: packages/rsbuild-config/dist
|
|
- name: Download i18n dist
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: i18n-dist
|
|
path: packages/i18n/dist
|
|
- name: Download Storybook Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: storybook-config-dist
|
|
path: packages/storybook-config/dist
|
|
- name: Lint WWW service
|
|
run: pnpm --filter @ermnvldmr/www lint
|
|
|
|
typecheck-www:
|
|
name: Typecheck - WWW
|
|
needs: build-configs
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9.12.3
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'pnpm'
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Download Rsbuild Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: rsbuild-config-dist
|
|
path: packages/rsbuild-config/dist
|
|
- name: Download i18n dist
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: i18n-dist
|
|
path: packages/i18n/dist
|
|
- name: Download Storybook Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: storybook-config-dist
|
|
path: packages/storybook-config/dist
|
|
- name: Typecheck WWW service
|
|
run: pnpm --filter @ermnvldmr/www typecheck
|
|
|
|
build-storybook:
|
|
name: Build - Storybook
|
|
needs: build-configs
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9.12.3
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'pnpm'
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Download Rsbuild Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: rsbuild-config-dist
|
|
path: packages/rsbuild-config/dist
|
|
- name: Download i18n dist
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: i18n-dist
|
|
path: packages/i18n/dist
|
|
- name: Download Storybook Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: storybook-config-dist
|
|
path: packages/storybook-config/dist
|
|
- name: Build WWW Storybook
|
|
run: pnpm --filter @ermnvldmr/www build-storybook
|
|
- name: Upload Storybook build
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: storybook-static
|
|
path: services/www/storybook-static/
|
|
retention-days: 1
|
|
|
|
test-www:
|
|
name: Test - Unit
|
|
needs: build-configs
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9.12.3
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'pnpm'
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Download Rsbuild Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: rsbuild-config-dist
|
|
path: packages/rsbuild-config/dist
|
|
- name: Download i18n dist
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: i18n-dist
|
|
path: packages/i18n/dist
|
|
- name: Download Storybook Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: storybook-config-dist
|
|
path: packages/storybook-config/dist
|
|
- name: Test WWW service
|
|
run: pnpm --filter @ermnvldmr/www test:coverage
|
|
- name: Upload Unit coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
files: ./services/www/coverage/lcov.info
|
|
flags: www
|
|
env:
|
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
test-storybook:
|
|
name: Test - Storybook
|
|
needs: build-storybook
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9.12.3
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'pnpm'
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Download Rsbuild Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: rsbuild-config-dist
|
|
path: packages/rsbuild-config/dist
|
|
- name: Download i18n dist
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: i18n-dist
|
|
path: packages/i18n/dist
|
|
- name: Download Storybook Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: storybook-config-dist
|
|
path: packages/storybook-config/dist
|
|
- name: Install Playwright browsers
|
|
run: pnpm --filter @ermnvldmr/www exec playwright install --with-deps chromium
|
|
- name: Download Storybook build
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: storybook-static
|
|
path: services/www/storybook-static/
|
|
- name: Serve Storybook and run tests with coverage
|
|
run: pnpm --filter @ermnvldmr/www test:storybook:ci
|
|
- name: Upload Storybook coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
with:
|
|
files: ./services/www/coverage/storybook/lcov.info
|
|
flags: www-storybook
|
|
env:
|
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
build-www:
|
|
name: Build - WWW Service
|
|
needs: build-configs
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9.12.3
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: 'pnpm'
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
- name: Download Rsbuild Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: rsbuild-config-dist
|
|
path: packages/rsbuild-config/dist
|
|
- name: Download i18n dist
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: i18n-dist
|
|
path: packages/i18n/dist
|
|
- name: Download Storybook Config
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: storybook-config-dist
|
|
path: packages/storybook-config/dist
|
|
- name: Build WWW service (all locales)
|
|
run: pnpm --filter @ermnvldmr/www build:all
|
|
env:
|
|
RSDOCTOR: 'true'
|
|
- name: Upload Rsdoctor report
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: rsdoctor-report
|
|
path: services/www/rsdoctor/
|
|
retention-days: 30
|
|
|
|
release-docker:
|
|
name: Release - Docker Image
|
|
needs: build-www
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ghcr.io/${{ github.repository }}/www
|
|
tags: |
|
|
type=raw,value=next
|
|
type=sha,format=short
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ci/docker/www/Dockerfile
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: |
|
|
COMMIT_SHA=sha-$(echo ${{ github.sha }} | cut -c1-7)
|
|
VERSION=sha-$(echo ${{ github.sha }} | cut -c1-7)
|
|
|
|
deploy:
|
|
name: Deploy - Kubernetes (GitOps)
|
|
needs: release-docker
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/next'
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: next
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Setup Kustomize
|
|
uses: imranismail/setup-kustomize@v2
|
|
with:
|
|
kustomize-version: "5.3.0"
|
|
|
|
- name: Deploy via GitOps
|
|
run: |
|
|
WWW_TAG="sha-$(echo ${{ github.sha }} | cut -c1-7)"
|
|
bash ci/scripts/deploy-gitops.sh www "${WWW_TAG}"
|
|
|
|
verify-rollout:
|
|
name: Verify - Production Rollout
|
|
needs: deploy
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/next'
|
|
steps:
|
|
- name: Await production rollout
|
|
run: |
|
|
TARGET_COMMIT="sha-$(echo ${{ github.sha }} | cut -c1-7)"
|
|
ENDPOINT="https://www.ermnvldmr.com/version.json"
|
|
|
|
echo "========================================================"
|
|
echo "Verifying production deployment on $ENDPOINT"
|
|
echo "Expected commit: $TARGET_COMMIT"
|
|
echo "========================================================"
|
|
|
|
MAX_ATTEMPTS=30
|
|
ATTEMPT=1
|
|
|
|
while [ $ATTEMPT -le $MAX_ATTEMPTS ]; do
|
|
echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: Polling $ENDPOINT..."
|
|
|
|
RESPONSE=$(curl -sf --max-time 10 "$ENDPOINT" 2>/dev/null || true)
|
|
|
|
if [ -n "$RESPONSE" ]; then
|
|
LIVE_COMMIT=$(echo "$RESPONSE" | jq -r '.commit // empty')
|
|
|
|
echo " Live commit: ${LIVE_COMMIT:-<none>}"
|
|
|
|
if [ "$LIVE_COMMIT" = "$TARGET_COMMIT" ]; then
|
|
echo "✅ Success! Production www has successfully rolled out $TARGET_COMMIT."
|
|
exit 0
|
|
fi
|
|
else
|
|
echo " Endpoint did not return valid JSON or timed out."
|
|
fi
|
|
|
|
ATTEMPT=$((ATTEMPT + 1))
|
|
sleep 10
|
|
done
|
|
|
|
echo "❌ Deployment verification timed out after 5 minutes."
|
|
exit 1
|