Skip to content

Commit a7d36a8

Browse files
Copilotneilime
andcommitted
refactor: implement repository_dispatch architecture for documentation sync
Co-authored-by: neilime <314088+neilime@users.noreply.github.com>
1 parent 9d5c4e5 commit a7d36a8

File tree

9 files changed

+1117
-341
lines changed

9 files changed

+1117
-341
lines changed

.github/EXAMPLES.md

Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
# Documentation Sync - Usage Examples
2+
3+
This document provides examples of how to use the repository_dispatch-based documentation sync system.
4+
5+
## Basic Examples
6+
7+
### Example 1: Basic Configuration
8+
9+
Minimal configuration for syncing documentation:
10+
11+
```yaml
12+
name: Push Documentation to Portal
13+
14+
on:
15+
push:
16+
branches:
17+
- main
18+
paths:
19+
- 'docs/**'
20+
- 'README.md'
21+
workflow_dispatch:
22+
23+
jobs:
24+
push-docs:
25+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@main
26+
with:
27+
source_repo: 'my-project'
28+
target_path: 'projects/my-project'
29+
secrets:
30+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
31+
```
32+
33+
### Example 2: Custom Documentation Path
34+
35+
If your documentation is in a non-standard location:
36+
37+
```yaml
38+
jobs:
39+
push-docs:
40+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@main
41+
with:
42+
source_repo: 'my-project'
43+
docs_path: 'documentation'
44+
target_path: 'projects/my-project'
45+
include_readme: false
46+
secrets:
47+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
48+
```
49+
50+
### Example 3: Sync from Multiple Branches
51+
52+
Sync documentation from both main and develop branches:
53+
54+
```yaml
55+
on:
56+
push:
57+
branches:
58+
- main
59+
- develop
60+
paths:
61+
- 'docs/**'
62+
- 'README.md'
63+
64+
jobs:
65+
push-docs-main:
66+
if: github.ref == 'refs/heads/main'
67+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@main
68+
with:
69+
source_repo: 'my-project'
70+
target_path: 'projects/my-project'
71+
branch: 'main'
72+
secrets:
73+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
74+
75+
push-docs-dev:
76+
if: github.ref == 'refs/heads/develop'
77+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@main
78+
with:
79+
source_repo: 'my-project'
80+
target_path: 'projects/my-project-dev'
81+
branch: 'develop'
82+
secrets:
83+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
84+
```
85+
86+
### Example 4: With Manual Trigger Only
87+
88+
For projects that want to control when documentation is synced:
89+
90+
```yaml
91+
on:
92+
workflow_dispatch:
93+
inputs:
94+
sync_readme:
95+
description: 'Include README.md'
96+
required: false
97+
type: boolean
98+
default: true
99+
100+
jobs:
101+
push-docs:
102+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@main
103+
with:
104+
source_repo: 'my-project'
105+
target_path: 'projects/my-project'
106+
include_readme: ${{ inputs.sync_readme }}
107+
secrets:
108+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
109+
```
110+
111+
## Testing
112+
113+
### Testing the Dispatcher
114+
115+
1. Set up the workflow in your project repository
116+
2. Add the `PUBLIC_DOCS_TOKEN` secret with `repo` scope
117+
3. Make a commit to `docs/**` or `README.md`
118+
4. Check the Actions tab in your repository for dispatcher execution
119+
5. Check the Actions tab in public-docs for receiver execution
120+
6. Verify the documentation appears in the portal
121+
122+
### Local Testing
123+
124+
You can't test the dispatcher locally, but you can validate your documentation:
125+
126+
```bash
127+
# In your project repository
128+
cd docs
129+
# Ensure all markdown files are valid
130+
find . -name "*.md" -exec markdown-lint {} \;
131+
```
132+
133+
## Troubleshooting
134+
135+
### Workflow not triggering
136+
137+
**Symptoms:**
138+
```
139+
No workflow runs appear in Actions tab
140+
```
141+
142+
**Solutions:**
143+
1. Verify the workflow file is in `.github/workflows/` directory
144+
2. Check the `paths` filter matches your documentation structure
145+
3. Ensure you're pushing to the correct branch
146+
4. Validate the workflow YAML syntax
147+
148+
### Token permission errors
149+
150+
**Symptoms:**
151+
```
152+
❌ Error: Resource not accessible by integration
153+
```
154+
155+
**Solutions:**
156+
1. Verify `PUBLIC_DOCS_TOKEN` secret exists in your repository
157+
2. Ensure the token has `repo` scope (not just `public_repo`)
158+
3. Confirm the token hasn't expired
159+
4. Test token permissions:
160+
```bash
161+
curl -H "Authorization: token $TOKEN" \
162+
https://api.github.com/repos/hoverkraft-tech/public-docs/dispatches
163+
```
164+
165+
### Documentation not appearing
166+
167+
**Symptoms:**
168+
```
169+
Dispatcher runs successfully but docs don't appear in portal
170+
```
171+
172+
**Solutions:**
173+
1. Check if receiver workflow ran in public-docs
174+
2. Review receiver workflow logs for build validation errors
175+
3. Verify the `target_path` is correct
176+
4. Ensure documentation files are `.md` or `.mdx`
177+
5. Check that frontmatter in docs is valid YAML
178+
179+
### Build validation fails
180+
181+
**Symptoms:**
182+
```
183+
Receiver workflow fails during build step
184+
```
185+
186+
**Solutions:**
187+
1. Review the build logs in the receiver workflow
188+
2. Common issues:
189+
- Invalid markdown syntax
190+
- Broken frontmatter YAML
191+
- Invalid relative links
192+
- Missing images or assets referenced in docs
193+
3. Test locally in public-docs:
194+
```bash
195+
# Clone public-docs
196+
git clone https://github.com/hoverkraft-tech/public-docs
197+
cd public-docs/application
198+
# Add your docs manually to test
199+
npm ci
200+
npm run build
201+
```
202+
203+
### Large documentation bundles
204+
205+
**Symptoms:**
206+
```
207+
❌ Error: Payload too large
208+
```
209+
210+
**Solutions:**
211+
1. GitHub Actions has limits on payload size
212+
2. Reduce documentation size:
213+
- Move large images to a separate hosting service
214+
- Split very large documents into smaller files
215+
- Exclude unnecessary files from docs directory
216+
3. Consider using git submodules for very large documentation sets
217+
218+
## Best Practices
219+
220+
1. **Keep documentation focused**: Only include necessary documentation files
221+
2. **Validate locally**: Test markdown and build before committing
222+
3. **Use frontmatter**: Add metadata to help with organization
223+
4. **Monitor workflows**: Check both dispatcher and receiver logs regularly
224+
5. **Test incrementally**: Push small changes to verify everything works
225+
6. **Use semantic paths**: Choose clear, descriptive target_path values
226+
227+
## Advanced Usage
228+
229+
### Conditional Syncing
230+
231+
Only sync when specific files change:
232+
233+
```yaml
234+
on:
235+
push:
236+
branches:
237+
- main
238+
paths:
239+
- 'docs/**/*.md'
240+
- '!docs/drafts/**'
241+
242+
jobs:
243+
push-docs:
244+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@main
245+
with:
246+
source_repo: 'my-project'
247+
target_path: 'projects/my-project'
248+
secrets:
249+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
250+
```
251+
252+
### Multiple Documentation Sections
253+
254+
Sync different documentation sections to different paths:
255+
256+
```yaml
257+
jobs:
258+
push-user-docs:
259+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@main
260+
with:
261+
source_repo: 'my-project'
262+
docs_path: 'docs/users'
263+
target_path: 'projects/my-project/users'
264+
secrets:
265+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
266+
267+
push-dev-docs:
268+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@main
269+
with:
270+
source_repo: 'my-project'
271+
docs_path: 'docs/developers'
272+
target_path: 'projects/my-project/developers'
273+
secrets:
274+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
275+
```

0 commit comments

Comments
 (0)