Skip to content

Commit 7cdd735

Browse files
Copilotneilime
andcommitted
feat: add push mode for real-time documentation sync via reusable workflow
Co-authored-by: neilime <314088+neilime@users.noreply.github.com>
1 parent f8b559b commit 7cdd735

File tree

6 files changed

+628
-32
lines changed

6 files changed

+628
-32
lines changed

.github/EXAMPLES.md

Lines changed: 107 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Documentation Aggregation - Usage Examples
22

3-
This document provides examples of how to use the documentation aggregation system.
3+
This document provides examples of how to use the documentation aggregation system in both pull and push modes.
44

5-
## Example 1: Basic Configuration
5+
## Pull Mode Examples
6+
7+
These examples are for the `.github/docs-sources.yml` configuration file.
8+
9+
### Example 1: Basic Configuration
610

711
Add a simple repository with documentation in a `docs/` folder:
812

@@ -79,9 +83,101 @@ repositories:
7983
description: API project with specific docs
8084
```
8185
86+
## Push Mode Examples
87+
88+
These examples are for workflows in **project repositories** that push their documentation to public-docs.
89+
90+
### Example 6: Basic Push Mode
91+
92+
Minimal configuration for pushing documentation on every commit:
93+
94+
```yaml
95+
name: Push Documentation to Portal
96+
97+
on:
98+
push:
99+
branches:
100+
- main
101+
paths:
102+
- 'docs/**'
103+
- 'README.md'
104+
workflow_dispatch:
105+
106+
jobs:
107+
push-docs:
108+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-push.yml@main
109+
with:
110+
source_repo: 'my-project'
111+
target_path: 'projects/my-project'
112+
secrets:
113+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
114+
```
115+
116+
### Example 7: Push with Custom Docs Path
117+
118+
If your documentation is in a non-standard location:
119+
120+
```yaml
121+
jobs:
122+
push-docs:
123+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-push.yml@main
124+
with:
125+
source_repo: 'my-project'
126+
docs_path: 'documentation'
127+
target_path: 'projects/my-project'
128+
include_readme: false
129+
secrets:
130+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
131+
```
132+
133+
### Example 8: Push from Multiple Branches
134+
135+
Sync documentation from both main and develop branches:
136+
137+
```yaml
138+
on:
139+
push:
140+
branches:
141+
- main
142+
- develop
143+
paths:
144+
- 'docs/**'
145+
- 'README.md'
146+
147+
jobs:
148+
push-docs-main:
149+
if: github.ref == 'refs/heads/main'
150+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-push.yml@main
151+
with:
152+
source_repo: 'my-project'
153+
target_path: 'projects/my-project'
154+
branch: 'main'
155+
secrets:
156+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
157+
158+
push-docs-dev:
159+
if: github.ref == 'refs/heads/develop'
160+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-push.yml@main
161+
with:
162+
source_repo: 'my-project'
163+
target_path: 'projects/my-project-dev'
164+
branch: 'develop'
165+
secrets:
166+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
167+
```
168+
169+
### Example 9: Combined Pull and Push
170+
171+
Use both modes for redundancy and verification:
172+
173+
1. **In project repository** - Add push workflow for immediate updates
174+
2. **In public-docs** - Keep pull configuration as backup
175+
176+
This ensures documentation is always up-to-date with push mode, while pull mode serves as a scheduled verification.
177+
82178
## Testing Locally
83179
84-
To test the documentation pull locally:
180+
### Testing Pull Mode
85181
86182
```bash
87183
# Set your GitHub token
@@ -98,6 +194,14 @@ ls -la docs/projects/
98194
npm run build
99195
```
100196

197+
### Testing Push Mode
198+
199+
Push mode can only be tested by:
200+
1. Setting up the workflow in your project repository
201+
2. Adding the `PUBLIC_DOCS_TOKEN` secret
202+
3. Making a commit to `docs/**` or `README.md`
203+
4. Checking the Actions tab for workflow execution
204+
101205
## Troubleshooting
102206

103207
### Repository not found

.github/README.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ This directory contains the scripts and configuration for aggregating documentat
44

55
## Overview
66

7-
The documentation aggregation system allows this portal to pull documentation content from individual project repositories while keeping the source of truth in each project.
7+
The documentation aggregation system supports **both pull and push modes** for syncing documentation from individual project repositories while keeping the source of truth in each project.
8+
9+
- **Pull Mode**: Portal pulls documentation on a schedule (daily)
10+
- **Push Mode**: Projects push documentation in real-time when changes occur
811

912
## Files
1013

1114
### Configuration
1215

13-
- **`docs-sources.yml`**: Configuration file defining which repositories to pull documentation from and how to organize it.
16+
- **`docs-sources.yml`**: Configuration file defining which repositories to pull documentation from (pull mode).
1417

1518
### Scripts
1619

@@ -19,7 +22,9 @@ The documentation aggregation system allows this portal to pull documentation co
1922

2023
### Workflows
2124

22-
- **`workflows/update-docs.yml`**: GitHub Actions workflow that runs the documentation synchronization daily and on demand.
25+
- **`workflows/update-docs.yml`**: GitHub Actions workflow for pull mode (runs daily and on demand).
26+
- **`workflows/sync-docs-push.yml`**: Reusable workflow for push mode (called by project repositories).
27+
- **`workflows/EXAMPLE-push-docs.yml.template`**: Example workflow template for project repositories to use.
2328

2429
## Quick Start
2530

@@ -48,6 +53,8 @@ The documentation aggregation system allows this portal to pull documentation co
4853

4954
### Adding a New Documentation Source
5055

56+
#### Option 1: Pull Mode (Scheduled)
57+
5158
1. Edit `docs-sources.yml`:
5259
```yaml
5360
repositories:
@@ -66,7 +73,39 @@ The documentation aggregation system allows this portal to pull documentation co
6673
git push
6774
```
6875

69-
3. The workflow will automatically sync the new documentation.
76+
3. The workflow will automatically sync the new documentation daily.
77+
78+
#### Option 2: Push Mode (Real-time) - Recommended
79+
80+
1. In the **project repository**, add `.github/workflows/push-docs.yml`:
81+
```yaml
82+
name: Push Documentation to Portal
83+
84+
on:
85+
push:
86+
branches:
87+
- main
88+
paths:
89+
- 'docs/**'
90+
- 'README.md'
91+
workflow_dispatch:
92+
93+
jobs:
94+
push-docs:
95+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-push.yml@main
96+
with:
97+
source_repo: 'my-new-project'
98+
docs_path: 'docs'
99+
target_path: 'projects/my-new-project'
100+
branch: 'main'
101+
include_readme: true
102+
secrets:
103+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
104+
```
105+
106+
2. Add `PUBLIC_DOCS_TOKEN` secret to the project repository.
107+
108+
3. Documentation will sync immediately on every commit to `docs/**` or `README.md`.
70109

71110
## Configuration Options
72111

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Example Workflow for Project Repositories
2+
#
3+
# This is a template that project repositories can use to automatically push
4+
# their documentation to the public-docs portal in real-time.
5+
#
6+
# To use this in your project repository:
7+
# 1. Copy this file to .github/workflows/push-docs.yml in your repository
8+
# 2. Update the inputs to match your project structure
9+
# 3. Add PUBLIC_DOCS_TOKEN secret to your repository with write access to public-docs
10+
# 4. Commit and push - your documentation will be synced automatically
11+
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+
# Allow manual triggering
23+
24+
jobs:
25+
push-docs:
26+
uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-push.yml@main
27+
with:
28+
source_repo: 'YOUR-REPO-NAME' # Replace with your repository name
29+
docs_path: 'docs' # Path to your documentation
30+
target_path: 'projects/YOUR-REPO-NAME' # Where to place docs in portal
31+
branch: 'main' # Branch to sync from
32+
include_readme: true # Include README.md
33+
secrets:
34+
PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
35+
36+
# Example configurations:
37+
38+
# Minimal configuration (uses defaults):
39+
# ---
40+
# jobs:
41+
# push-docs:
42+
# uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-push.yml@main
43+
# with:
44+
# source_repo: 'compose-action'
45+
# target_path: 'projects/compose-action'
46+
# secrets:
47+
# PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
48+
49+
# Custom documentation path:
50+
# ---
51+
# jobs:
52+
# push-docs:
53+
# uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-push.yml@main
54+
# with:
55+
# source_repo: 'my-project'
56+
# docs_path: 'documentation'
57+
# target_path: 'projects/my-project'
58+
# include_readme: false
59+
# secrets:
60+
# PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}
61+
62+
# Sync from development branch:
63+
# ---
64+
# jobs:
65+
# push-docs:
66+
# uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-push.yml@main
67+
# with:
68+
# source_repo: 'my-project'
69+
# target_path: 'projects/my-project'
70+
# branch: 'develop'
71+
# secrets:
72+
# PUBLIC_DOCS_TOKEN: ${{ secrets.PUBLIC_DOCS_TOKEN }}

0 commit comments

Comments
 (0)