-
Notifications
You must be signed in to change notification settings - Fork 0
372 lines (304 loc) · 12.2 KB
/
Copy pathsync-docs.yml
File metadata and controls
372 lines (304 loc) · 12.2 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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
name: Sync Documentation
on:
push:
branches: [ main, develop ]
paths:
- 'docs/**'
- 'README.md'
- '.github/workflows/sync-docs.yml'
workflow_dispatch:
inputs:
force_sync:
description: 'Force sync even if no changes detected'
required: false
default: false
type: boolean
permissions:
contents: read
actions: read
jobs:
sync-docs:
runs-on: ubuntu-latest
if: github.repository == 'altus4/website'
steps:
- name: Checkout source repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_TOKEN }}
- name: Configure Git
run: |
git config --global user.name "docs-sync-bot"
git config --global user.email "bot@altus4.dev"
- name: Validate token access
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
if [ -z "$GH_TOKEN" ]; then
echo "ERROR: GH_TOKEN is not set or is empty"
exit 1
else
echo "SUCCESS: GH_TOKEN is set"
# Test token by making a simple API call
curl -s -H "Authorization: token $GH_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/user | jq -r '.login // "Token validation failed"'
fi
- name: Check for docs changes
id: check_changes
run: |
if [ "${{ github.event.inputs.force_sync }}" = "true" ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Force sync requested"
elif git diff --quiet HEAD~1 HEAD -- docs/ README.md; then
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No changes in docs directory"
else
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Changes detected in docs directory"
fi
- name: Get commit info
id: commit_info
if: steps.check_changes.outputs.has_changes == 'true'
run: |
COMMIT_SHA="${{ github.sha }}"
COMMIT_MSG=$(git log -1 --pretty=format:"%s" $COMMIT_SHA)
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an" $COMMIT_SHA)
COMMIT_DATE=$(git log -1 --pretty=format:"%ci" $COMMIT_SHA)
echo "sha=${COMMIT_SHA:0:7}" >> $GITHUB_OUTPUT
echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT
echo "author=$COMMIT_AUTHOR" >> $GITHUB_OUTPUT
echo "date=$COMMIT_DATE" >> $GITHUB_OUTPUT
- name: Sync to docs repository
if: steps.check_changes.outputs.has_changes == 'true'
env:
DOCS_REPO_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
# Configuration
DOCS_REPO_URL="https://x-access-token:${DOCS_REPO_TOKEN}@github.com/altus4/docs.git"
TEMP_DIR="/tmp/altus4-docs-sync"
COMMIT_MESSAGE="docs: sync from ${{ steps.commit_info.outputs.sha }} - ${{ steps.commit_info.outputs.message }}"
echo "Starting documentation sync..."
echo "Commit: ${{ steps.commit_info.outputs.message }}"
echo "Author: ${{ steps.commit_info.outputs.author }}"
echo "Date: ${{ steps.commit_info.outputs.date }}"
# Clean up any existing temp directory
rm -rf "$TEMP_DIR"
mkdir -p "$TEMP_DIR"
cd "$TEMP_DIR"
# Clone the docs repository
echo "Cloning altus4/docs repository..."
git clone "$DOCS_REPO_URL" .
# Remove all existing files except .git
echo "Clearing existing content..."
find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
# Copy docs directory contents
echo "Copying documentation files..."
cp -r "$GITHUB_WORKSPACE/docs/"* .
# Copy README from main repository
if [ -f "$GITHUB_WORKSPACE/README.md" ]; then
cp "$GITHUB_WORKSPACE/README.md" ./MAIN_README.md
fi
# Get current date for README
CURRENT_DATE=$(date '+%Y-%m-%d')
CURRENT_DATETIME=$(date '+%Y-%m-%d %H:%M:%S UTC')
# Create docs-specific README
cat > README.md << EOF
# Altus 4 Documentation


This repository contains the documentation for **Altus 4** - AI-Enhanced MySQL Full-Text Search Engine.
## View Documentation
**Live Documentation**: [https://altus4.thavarshan.com/docs](https://altus4.thavarshan.com/docs)
## Auto-Synchronization
This repository is automatically synchronized from the main [altus4/core](https://github.com/altus4/core) repository.
- **Source**: \`docs/\` directory in the main repository
- **Sync Trigger**: Any push to \`main\` or \`develop\` branch that modifies documentation
- **Last Sync**: ${CURRENT_DATETIME}
- **Source Commit**: [${{ steps.commit_info.outputs.sha }}](https://github.com/altus4/core/commit/${{ github.sha }})
## Contributing
**Do not make direct changes to this repository!**
To contribute to the documentation:
1. Fork the [main repository](https://github.com/altus4/core)
2. Make changes to the \`docs/\` directory
3. Submit a pull request to the main repository
4. Changes will be automatically synced here upon merge
## Local Development
To work with the documentation locally:
\`\`\`bash
# Clone the main repository
git clone https://github.com/altus4/core.git
cd altus4/docs
# Install dependencies
npm install
# Start development server
npm run docs:dev
# Build for production
npm run docs:build
\`\`\`
## Documentation Structure
- **[Setup Guide](./setup/)** - Installation and deployment
- **[API Reference](./api/)** - Complete API documentation
- **[Architecture](./architecture/)** - System design and patterns
- **[Services](./services/)** - Service layer documentation
- **[Examples](./examples/)** - Code examples and tutorials
- **[Development](./development/)** - Contributing guidelines
- **[Testing](./testing/)** - Testing strategies and examples
## Automation Details
This repository uses GitHub Actions for:
- **Auto-sync** from main repository
- **Auto-build** documentation site
- **Auto-deploy** to GitHub Pages
## License
This documentation is part of the Altus 4 project. See the [main repository](https://github.com/altus4/core) for license information.
EOF
# Create package.json
cat > package.json << 'EOF'
{
"name": "@altus4/docs",
"version": "1.0.0",
"description": "Documentation for Altus 4 - AI-Enhanced MySQL Full-Text Search Engine",
"scripts": {
"docs:dev": "vitepress dev . --port 5174",
"docs:build": "vitepress build .",
"docs:preview": "vitepress preview ."
},
"keywords": [
"altus4",
"documentation",
"mysql",
"search",
"ai",
"vitepress"
],
"repository": {
"type": "git",
"url": "https://github.com/altus4/docs.git"
},
"homepage": "https://altus4.thavarshan.com/docs",
"devDependencies": {
"vitepress": "^2.0.0-alpha.12"
}
}
EOF
# Create .gitignore
cat > .gitignore << 'EOF'
# Dependencies
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# VitePress
.vitepress/cache/
.vitepress/dist/
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# IDE files
.vscode/
.idea/
*.swp
*.swo
*~
# Logs
logs/
*.log
# Runtime data
pids/
*.pid
*.seed
*.pid.lock
# Coverage directory used by tools like istanbul
coverage/
# Temporary folders
tmp/
temp/
EOF
# Create GitHub Pages workflow
mkdir -p .github/workflows
cat > .github/workflows/deploy.yml << 'EOF'
name: Deploy Documentation to GitHub Pages
on:
push:
branches: [ main ]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build documentation
run: npm run docs:build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: .vitepress/dist
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
EOF
# Check if there are any changes
if git diff --quiet && git diff --cached --quiet; then
echo "WARNING: No changes to sync"
else
echo "SUCCESS: Changes detected, committing and pushing..."
# Stage all changes
git add .
# Commit changes
git commit -m "$COMMIT_MESSAGE"
# Push to remote
echo "Pushing changes to altus4/docs repository..."
git push origin main
echo "SUCCESS: Documentation sync completed successfully!"
fi
- name: Create sync summary
if: steps.check_changes.outputs.has_changes == 'true'
run: |
echo "## Documentation Sync Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Status**: Successfully synced to [altus4/docs](https://github.com/altus4/docs)" >> $GITHUB_STEP_SUMMARY
echo "**Source Commit**: [${{ steps.commit_info.outputs.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})" >> $GITHUB_STEP_SUMMARY
echo "**Commit Message**: ${{ steps.commit_info.outputs.message }}" >> $GITHUB_STEP_SUMMARY
echo "**Author**: ${{ steps.commit_info.outputs.author }}" >> $GITHUB_STEP_SUMMARY
echo "**Documentation Site**: [https://altus4.thavarshan.com/docs](https://altus4.thavarshan.com/docs)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The documentation will be automatically deployed to GitHub Pages within a few minutes." >> $GITHUB_STEP_SUMMARY
- name: No changes summary
if: steps.check_changes.outputs.has_changes == 'false'
run: |
echo "## Documentation Sync Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Status**: No changes detected in documentation" >> $GITHUB_STEP_SUMMARY
echo "**Checked Paths**: \`docs/\`, \`README.md\`" >> $GITHUB_STEP_SUMMARY
echo "**Current Documentation**: [https://altus4.thavarshan.com/docs](https://altus4.thavarshan.com/docs)" >> $GITHUB_STEP_SUMMARY