-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (88 loc) · 3.37 KB
/
deploy-docs.yml
File metadata and controls
103 lines (88 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Deploy Docs Workflow
#
# This workflow builds the documentation and deploys to Cloudflare Pages.
# The dev branch deploys to stackwright-docs-dev for preview/testing.
# The main branch deploys to stackwright-docs for production.
# Required secrets for Pages deployment:
# - CLOUDFLARE_API_TOKEN: Cloudflare API token with Pages edit permissions
# - CLOUDFLARE_ACCOUNT_ID: Cloudflare account ID
name: Deploy Docs to Pages
on:
push:
branches:
- dev
- main
paths:
- '.github/workflows/deploy-docs.yml'
- 'examples/stackwright-docs/**'
- 'packages/**'
permissions:
contents: read
id-token: write
jobs:
deploy-docs:
name: Deploy Documentation
runs-on: ubuntu-latest
timeout-minutes: 45 # combined build + deploy
environment:
name: ${{ github.ref_name == 'main' && 'production' || 'development' }}
steps:
# ============================================
# Build Steps
# ============================================
- name: Checkout repository
uses: actions/checkout@v5 # was v4, now v5
with:
# Full history needed for changeset version detection
fetch-depth: 0
- name: Install pnpm
run: npm install -g pnpm@10.33.0
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '22'
- name: Install dependencies
run: pnpm install --frozen-lockfile
env:
# Speed up installation by skipping optional packages
PNPM_SKIP_OPTIONAL_PACKAGES: 'true'
- name: Build monorepo packages
run: pnpm build
- name: Build documentation site
run: |
cd examples/stackwright-docs
node ../../packages/build-scripts/dist/prebuild.js
npx next build
# ============================================
# Deploy Steps
# ============================================
- name: Set deployment variables
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
echo "DEPLOY_PROJECT=stackwright-docs" >> $GITHUB_ENV
echo "DEPLOY_ENV=production" >> $GITHUB_ENV
else
echo "DEPLOY_PROJECT=stackwright-docs-dev" >> $GITHUB_ENV
echo "DEPLOY_ENV=development" >> $GITHUB_ENV
fi
echo "Selected project: ${{ env.DEPLOY_PROJECT }}"
- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ env.DEPLOY_PROJECT }}
directory: examples/stackwright-docs/out
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Deployment summary
run: |
echo "## Deployment Complete 🚀" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Detail | Value |" >> $GITHUB_STEP_SUMMARY
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| Branch | \`${{ github.ref_name }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| Environment | ${{ env.DEPLOY_ENV }} |" >> $GITHUB_STEP_SUMMARY
echo "| Project | \`${{ env.DEPLOY_PROJECT }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| Commit | \`${{ github.sha }}\` |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Deployed to Cloudflare Pages**"