1+ name : Deploy to GitHub Pages
2+
3+ on :
4+ push :
5+ branches : [ main, v2-static-site ]
6+ pull_request :
7+ branches : [ main ]
8+ workflow_dispatch :
9+
10+ permissions :
11+ contents : read
12+ pages : write
13+ id-token : write
14+
15+ concurrency :
16+ group : " pages"
17+ cancel-in-progress : false
18+
19+ jobs :
20+ validate-attestations :
21+ runs-on : ubuntu-latest
22+ steps :
23+ - name : Checkout
24+ uses : actions/checkout@v4
25+
26+ - name : Setup Node.js
27+ uses : actions/setup-node@v4
28+ with :
29+ node-version : ' 20'
30+
31+ - name : Validate attestation files
32+ run : |
33+ # Validate all attestation JSON files
34+ for file in attestations/v2/*.json; do
35+ if [ -f "$file" ]; then
36+ echo "Validating $file..."
37+ node -e "
38+ const fs = require('fs');
39+ const content = fs.readFileSync('$file', 'utf8');
40+ try {
41+ const attestation = JSON.parse(content);
42+ // Basic validation
43+ if (!attestation.version || !attestation.id || !attestation.content_hash) {
44+ throw new Error('Missing required fields');
45+ }
46+ console.log(' Valid attestation');
47+ } catch (e) {
48+ console.error(' Invalid attestation:', e.message);
49+ process.exit(1);
50+ }
51+ "
52+ fi
53+ done
54+
55+ build-stats :
56+ runs-on : ubuntu-latest
57+ needs : validate-attestations
58+ steps :
59+ - name : Checkout
60+ uses : actions/checkout@v4
61+
62+ - name : Generate statistics
63+ run : |
64+ # Count attestations and generate stats
65+ echo "Generating attestation statistics..."
66+
67+ # Create a stats.json file
68+ node -e "
69+ const fs = require('fs');
70+ const path = require('path');
71+
72+ // Count attestations
73+ let v1Count = 0;
74+ let v2Count = 0;
75+ const models = new Set();
76+
77+ // Count v2 attestations
78+ const v2Dir = 'attestations/v2';
79+ if (fs.existsSync(v2Dir)) {
80+ const files = fs.readdirSync(v2Dir);
81+ files.forEach(file => {
82+ if (file.endsWith('.json')) {
83+ v2Count++;
84+ try {
85+ const content = fs.readFileSync(path.join(v2Dir, file), 'utf8');
86+ const attestation = JSON.parse(content);
87+ if (attestation.model) {
88+ models.add(attestation.model);
89+ }
90+ } catch (e) {}
91+ }
92+ });
93+ }
94+
95+ // Count legacy attestations (directories named with numbers)
96+ for (let i = 1; i <= 999; i++) {
97+ if (fs.existsSync(String(i))) {
98+ v1Count++;
99+ }
100+ }
101+
102+ const stats = {
103+ total: v1Count + v2Count,
104+ v1: v1Count,
105+ v2: v2Count,
106+ models: models.size,
107+ lastUpdated: new Date().toISOString()
108+ };
109+
110+ fs.writeFileSync('static/stats.json', JSON.stringify(stats, null, 2));
111+ console.log('Stats generated:', stats);
112+ "
113+
114+ - name : Upload stats artifact
115+ uses : actions/upload-artifact@v4
116+ with :
117+ name : stats
118+ path : static/stats.json
119+
120+ deploy :
121+ environment :
122+ name : github-pages
123+ url : ${{ steps.deployment.outputs.page_url }}
124+ runs-on : ubuntu-latest
125+ needs : build-stats
126+ steps :
127+ - name : Checkout
128+ uses : actions/checkout@v4
129+
130+ - name : Download stats artifact
131+ uses : actions/download-artifact@v4
132+ with :
133+ name : stats
134+ path : static/
135+
136+ - name : Create 404 page
137+ run : |
138+ cat > 404.html << 'EOF'
139+ <!DOCTYPE html>
140+ <html lang="en">
141+ <head>
142+ <meta charset="UTF-8">
143+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
144+ <title>404 - Page Not Found | attest.ink</title>
145+ <link rel="stylesheet" href="/static/style.css">
146+ </head>
147+ <body>
148+ <header>
149+ <nav>
150+ <div class="container">
151+ <a href="/" class="logo">attest.ink</a>
152+ <ul>
153+ <li><a href="/create/">Create</a></li>
154+ <li><a href="/view/">Verify</a></li>
155+ <li><a href="/developers/">Developers</a></li>
156+ <li><a href="/protocol/">Protocol</a></li>
157+ </ul>
158+ </div>
159+ </nav>
160+ </header>
161+ <main style="text-align: center; padding: 4rem 0;">
162+ <h1>404 - Page Not Found</h1>
163+ <p>The attestation or page you're looking for doesn't exist.</p>
164+ <a href="/" class="btn btn-primary">Go Home</a>
165+ </main>
166+ </body>
167+ </html>
168+ EOF
169+
170+ - name : Setup Pages
171+ uses : actions/configure-pages@v4
172+
173+ - name : Upload artifact
174+ uses : actions/upload-pages-artifact@v3
175+ with :
176+ path : ' .'
177+
178+ - name : Deploy to GitHub Pages
179+ id : deployment
180+ uses : actions/deploy-pages@v4
181+
182+ verify-deployment :
183+ runs-on : ubuntu-latest
184+ needs : deploy
185+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
186+ steps :
187+ - name : Wait for deployment
188+ run : sleep 30
189+
190+ - name : Verify deployment
191+ run : |
192+ # Test key endpoints
193+ urls=(
194+ "https://attest.ink/"
195+ "https://attest.ink/create/"
196+ "https://attest.ink/view/"
197+ "https://attest.ink/developers/"
198+ "https://attest.ink/protocol/"
199+ "https://attest.ink/static/badge-renderer.js"
200+ "https://attest.ink/static/attestation-tool.js"
201+ )
202+
203+ for url in "${urls[@]}"; do
204+ echo "Testing $url..."
205+ if curl -f -s -o /dev/null "$url"; then
206+ echo " $url is accessible"
207+ else
208+ echo " $url failed"
209+ exit 1
210+ fi
211+ done
212+
213+ echo "All endpoints verified successfully!"
0 commit comments