Files
Owen/.github/workflows/demo-deployment.yml
dependabot[bot] 0595bf0a82 ci(deps): bump peaceiris/actions-gh-pages from 3 to 4
Bumps [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages) from 3 to 4.
- [Release notes](https://github.com/peaceiris/actions-gh-pages/releases)
- [Changelog](https://github.com/peaceiris/actions-gh-pages/blob/main/CHANGELOG.md)
- [Commits](https://github.com/peaceiris/actions-gh-pages/compare/v3...v4)

---
updated-dependencies:
- dependency-name: peaceiris/actions-gh-pages
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-24 03:40:52 +00:00

247 lines
6.3 KiB
YAML

name: Demo Deployment
on:
push:
branches: [ main, master ]
paths:
- 'demo/**'
- 'src/**'
- 'vite.demo.config.js'
- 'package.json'
pull_request:
branches: [ main, master ]
paths:
- 'demo/**'
- 'src/**'
- 'vite.demo.config.js'
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
default: 'staging'
type: choice
options:
- staging
- production
env:
NODE_VERSION: '20.x'
jobs:
build-demo:
name: Build Demo
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Generate animation constants
run: npm run generate:constants
- name: Build demo application
run: npm run build:demo
env:
NODE_ENV: production
- name: Validate demo build
run: |
test -d dist/demo || (echo "Demo build failed - dist/demo directory not found" && exit 1)
test -f dist/demo/index.html || (echo "Demo build failed - index.html not found" && exit 1)
test -f dist/demo/examples.html || (echo "Demo build failed - examples.html not found" && exit 1)
test -f dist/demo/comparison.html || (echo "Demo build failed - comparison.html not found" && exit 1)
test -f dist/demo/interactive.html || (echo "Demo build failed - interactive.html not found" && exit 1)
- name: Upload demo artifacts
uses: actions/upload-artifact@v4
with:
name: demo-build
path: dist/demo/
retention-days: 30
- name: Upload build reports
uses: actions/upload-artifact@v4
with:
name: build-reports
path: |
dist/demo/report.html
dist/demo/stats.json
retention-days: 7
test-demo:
name: Test Demo
runs-on: ubuntu-latest
needs: build-demo
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Download demo build
uses: actions/download-artifact@v4
with:
name: demo-build
path: dist/demo/
- name: Install Playwright
run: npx playwright install --with-deps
- name: Run demo tests
run: npm run test:demo
env:
CI: true
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/ms-playwright
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 7
- name: Upload test screenshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-screenshots
path: test-results/
retention-days: 7
lighthouse-audit:
name: Performance Audit
runs-on: ubuntu-latest
needs: build-demo
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Download demo build
uses: actions/download-artifact@v4
with:
name: demo-build
path: dist/demo/
- name: Install Lighthouse
run: npm install -g @lhci/cli lighthouse
- name: Start demo server
run: |
npx vite preview --config vite.demo.config.js --port 3000 &
sleep 10
env:
NODE_ENV: production
- name: Run Lighthouse audit
run: |
lhci autorun
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
- name: Upload Lighthouse results
uses: actions/upload-artifact@v4
with:
name: lighthouse-reports
path: .lighthouseci/
retention-days: 7
deploy-staging:
name: Deploy to Staging
runs-on: ubuntu-latest
needs: [build-demo, test-demo]
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || github.event.inputs.environment == 'staging'
environment: staging
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download demo build
uses: actions/download-artifact@v4
with:
name: demo-build
path: dist/demo/
- name: Deploy to staging
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist/demo
publish_branch: gh-pages-staging
force_orphan: true
- name: Update deployment status
run: |
echo "Demo deployed to staging: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/staging/"
deploy-production:
name: Deploy to Production
runs-on: ubuntu-latest
needs: [build-demo, test-demo, lighthouse-audit]
if: github.ref == 'refs/heads/main' && github.event.inputs.environment == 'production'
environment: production
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download demo build
uses: actions/download-artifact@v4
with:
name: demo-build
path: dist/demo/
- name: Deploy to production
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist/demo
publish_branch: gh-pages
force_orphan: true
- name: Update deployment status
run: |
echo "Demo deployed to production: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/"
- name: Create deployment notification
uses: actions/github-script@v7
with:
script: |
github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: context.payload.deployment.id,
state: 'success',
environment_url: 'https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/',
description: 'Demo successfully deployed'
});