-
Notifications
You must be signed in to change notification settings - Fork 0
345 lines (298 loc) Β· 10.6 KB
/
deploy.yml
File metadata and controls
345 lines (298 loc) Β· 10.6 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
name: Deploy Documentation
on:
push:
branches:
- main # Auto-deploy to dev
tags:
- 'v*' # Deploy to prod on version tags
pull_request:
branches:
- main # Validate PRs
workflow_dispatch: # Manual trigger
inputs:
environment:
description: 'Environment to deploy to'
required: true
type: choice
options:
- dev
- prod
# Cancel in-progress runs for same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Required permissions for GitHub Deployments and Cloudflare Pages
permissions:
contents: write # Changed from read to write for commit comments
deployments: write
pull-requests: write
jobs:
# Build unified documentation (runs for all triggers)
build:
runs-on: ubuntu-latest
steps:
- name: Checkout capiscio-docs
uses: actions/checkout@v4
with:
path: capiscio-docs
fetch-depth: 0 # Full history for git-revision-date plugin
- name: Checkout capiscio-core
uses: actions/checkout@v4
with:
repository: capiscio/capiscio-core
path: capiscio-core
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout capiscio-sdk-python
uses: actions/checkout@v4
with:
repository: capiscio/capiscio-sdk-python
path: capiscio-sdk-python
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout capiscio-python
uses: actions/checkout@v4
with:
repository: capiscio/capiscio-python
path: capiscio-python
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout capiscio-node
uses: actions/checkout@v4
with:
repository: capiscio/capiscio-node
path: capiscio-node
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout validate-a2a
uses: actions/checkout@v4
with:
repository: capiscio/validate-a2a
path: validate-a2a
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout capiscio-rfcs
uses: actions/checkout@v4
with:
repository: capiscio/capiscio-rfcs
path: capiscio-rfcs
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout capiscio-mcp-python
uses: actions/checkout@v4
with:
repository: capiscio/capiscio-mcp-python
path: capiscio-mcp-python
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
# Install capiscio-sdk-python with all its dependencies (pydantic, etc.)
# The [dev] extra ensures all optional deps are available for mkdocstrings
pip install -e "capiscio-sdk-python[dev]"
# Now install docs requirements
cd capiscio-docs
pip install -r requirements-docs.txt
- name: Build documentation
run: |
cd capiscio-docs
mkdocs build --strict --verbose
env:
ENABLE_MONOREPO: 'true'
ENABLE_GIT_DATES: 'true'
- name: Copy _redirects to site root
run: |
cp capiscio-docs/docs/_redirects capiscio-docs/site/_redirects
- name: Create _headers file for Cloudflare
run: |
cd capiscio-docs/site
cat > _headers << 'EOF'
/*
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: geolocation=(), microphone=(), camera=()
Cache-Control: public, max-age=3600, must-revalidate
/*.html
Cache-Control: public, max-age=600, must-revalidate
/assets/*
Cache-Control: public, max-age=31536000, immutable
/sitemap.xml
Cache-Control: public, max-age=3600
EOF
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: documentation
path: capiscio-docs/site/
retention-days: 7
# Deploy to DEV (automatic on main push or manual)
deploy-dev:
needs: build
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && inputs.environment == 'dev')
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: documentation
path: site/
- name: Block search engines (Dev only)
run: |
cd site
# Override robots.txt to block all crawlers
cat > robots.txt << 'EOF'
User-agent: *
Disallow: /
EOF
# Add X-Robots-Tag header to prevent indexing
cat > _headers << 'EOF'
/*
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: geolocation=(), microphone=(), camera=()
X-Robots-Tag: noindex, nofollow
Cache-Control: public, max-age=600, must-revalidate
/*.html
Cache-Control: public, max-age=300, must-revalidate
/assets/*
Cache-Control: public, max-age=31536000, immutable
EOF
- name: Deploy to Cloudflare Pages (Dev)
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: capiscio-docs-dev
directory: site
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: main
wranglerVersion: '3'
- name: Comment on commit
if: github.event_name == 'push'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const sha = context.sha;
const message = `## π Dev Deployment Complete
π **Environment:** Development
π **URL:** https://dev-docs.capisc.io
π **Commit:** ${sha.substring(0, 7)}
> Auto-deployed from main branch`;
github.rest.repos.createCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: sha,
body: message
});
# Deploy to PROD (on version tags or manual)
deploy-prod:
needs: build
if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
(github.event_name == 'workflow_dispatch' && inputs.environment == 'prod')
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: documentation
path: site/
- name: Deploy to Cloudflare Pages (Production)
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: capiscio-docs
directory: site
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: main
wranglerVersion: '3'
- name: Create release comment
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = context.ref.replace('refs/tags/', '');
const message = `## π Production Deployment Complete
π **Environment:** Production
π **URL:** https://docs.capisc.io
π·οΈ **Version:** ${tag}
Documentation has been deployed to production!`;
// Create a release if it doesn't exist
try {
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: `Documentation ${tag}`,
body: message,
draft: false,
prerelease: false
});
} catch (error) {
console.log('Release might already exist:', error.message);
}
- name: Check links (Production only)
run: |
pip install linkchecker
# Wait for propagation
sleep 30
linkchecker https://docs.capisc.io --no-warnings --ignore-url=/search || true
continue-on-error: true
# PR Validation (no deployment)
validate-pr:
needs: build
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: documentation
path: site/
- name: Check for broken links
run: |
pip install linkchecker
cd site
python -m http.server 8000 &
sleep 5
linkchecker http://localhost:8000 --no-warnings --check-extern || true
continue-on-error: true
- name: Validate build
run: |
cd site
# Check that critical files exist
test -f index.html
test -f sitemap.xml
test -f robots.txt
echo "β
Build validation passed"
- name: Add validation comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.pull_request.number;
const comment = `## β
Documentation Build Successful
The documentation build completed successfully and passed validation checks.
- β
Build completed without errors
- β
Critical files present (index.html, sitemap.xml, robots.txt)
- β
Link validation completed
> This PR will deploy to **dev-docs.capisc.io** when merged to main.
`;
github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});