2121
2222## Overview
2323
24- ** Reusable workflow** (not an action) that bundles project docs and triggers public portal sync.
24+ Reusable workflow that bundles project docs and triggers public portal sync
2525
26- - This is a ** workflow-level** component: use ` uses: ` at the ** job level** in your workflow
2726- Collects readme and docs Markdown, adds sync metadata, and uploads a short-lived artifact
2827- Dispatches a repository event so hoverkraft-tech/public-docs can ingest and publish updates
2928
3029<!-- overview:end -->
3130
31+ ## Important Note
32+
33+ ** This is a reusable workflow** (job-level ` uses: ` ), ** not an action** (step-level ` uses: ` ). It must be called at the job level in your workflow file.
34+
3235## Quick Start
3336
3437### Prerequisites
3538
36391 . ** GitHub App Token** configured in your repository:
3740 - Required scopes: ` repo ` (for repository_dispatch) and artifact access
38- - Add ` PUBLIC_DOCS_APP_ID ` and ` PUBLIC_DOCS_APP_PRIVATE_KEY ` to repository secrets
39- - Settings → Secrets and variables → Actions → New repository secret
41+ - Add ` PUBLIC_DOCS_APP_ID ` as a repository ** variable**
42+ - Add ` PUBLIC_DOCS_APP_PRIVATE_KEY ` as a repository ** secret**
43+ - Settings → Secrets and variables → Actions
4044
41452 . ** Documentation files** in your project repository:
4246
@@ -49,13 +53,7 @@ your-project/
4953└── .github/workflows/*.md # Workflow documentation (optional)
5054```
5155
52- <!-- usage:start -->
53-
54- ## Usage
55-
56- ### Complete Workflow Example
57-
58- This is a ** reusable workflow** , not an action. It must be called at the ** job level** using ` uses: ` .
56+ ### Complete Integration Example
5957
6058``` yaml
6159name : Main CI
@@ -77,10 +75,27 @@ jobs:
7775 - name : Run tests
7876 run : npm test
7977
80- sync -docs :
81- name : Sync Documentation
78+ prepare -docs :
79+ name : Prepare Documentation
8280 needs : ci
8381 if : github.event_name != 'schedule' && github.ref == 'refs/heads/main'
82+ runs-on : ubuntu-latest
83+ permissions :
84+ contents : read
85+ steps :
86+ - uses : actions/checkout@v4
87+
88+ - name : Prepare documentation
89+ uses : hoverkraft-tech/public-docs/.github/actions/prepare-docs@18facec04f2945f4d66d510e8a06568497b73c54 # 0.1.0
90+ with :
91+ paths : |
92+ README.md
93+ docs/**/*.md
94+ .github/workflows/*.md
95+
96+ sync-docs :
97+ name : Sync Documentation
98+ needs : prepare-docs
8499 permissions :
85100 contents : read
86101 uses : hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@18facec04f2945f4d66d510e8a06568497b73c54 # 0.1.0
@@ -93,34 +108,44 @@ jobs:
93108
94109### Key Integration Points
95110
96- 1. **Job-level usage **: Use ` uses:` at the job level ( not as a step)
111+ 1. **Workflow vs Action **: This is a **reusable workflow** - use ` uses:` at the ** job level**, not as a step
971122. **Version pinning** : Always pin to a specific commit SHA for security
981133. **Conditional execution** : Skip on scheduled runs with `if: github.event_name != 'schedule'`
991144. **Main branch only** : Typically only sync from main/default branch
1001155. **After CI** : Add as a job that runs after your primary CI job completes
116+ 6. **Prepare first** : Use the prepare-docs action before calling this workflow
117+
118+ <!-- usage:start -->
101119
102- # ## Input Parameters Reference
120+ # # Usage
103121
104122` ` ` yaml
105- sync-docs:
106- uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@<commit-sha>
107- with:
108- # GitHub App ID to generate GitHub token in place of github-token.
109- # See https://github.com/actions/create-github-app-token.
110- github-app-id: ${{ vars.PUBLIC_DOCS_APP_ID }}
111-
112- # ID of the uploaded documentation artifact.
113- # This input is required.
114- artifact-id: "docs"
115- secrets:
116- # GitHub App private key to generate GitHub token in place of github-token.
117- # See https://github.com/actions/create-github-app-token.
118- github-app-key: ${{ secrets.PUBLIC_DOCS_APP_PRIVATE_KEY }}
123+ name: Push Documentation Helper
124+ on:
125+ push:
126+ branches:
127+ - main
128+ jobs:
129+ sync-docs-dispatcher:
130+ uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@cd3f060f4c823de3294a7498b8a8617723b8cf53 # 0.2.0
131+ secrets:
132+ # GitHub App private key to generate GitHub token in place of github-token.
133+ # See https://github.com/actions/create-github-app-token.
134+ github-app-key: ""
135+ with:
136+ # GitHub App ID to generate GitHub token in place of github-token.
137+ # See https://github.com/actions/create-github-app-token.
138+ github-app-id: ""
139+
140+ # ID of the uploaded documentation artifact.
141+ #
142+ # This input is required.
143+ artifact-id: ""
119144` ` `
120145
121146<!-- usage:end -->
122147
123- # # Best Practices
148+ # # Implementation Guide
124149
125150# ## GitHub App Token Setup
126151
@@ -172,7 +197,69 @@ uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@18f
172197# 3. Keeping version comment concise
173198` ` `
174199
175- # ## Documentation Content Best Practices
200+ # ## Path Pattern Recommendations
201+
202+ When using the prepare-docs action, use **specific glob patterns** for Markdown files only :
203+
204+ ` ` ` yaml
205+ # ✅ GOOD: Specific patterns for documentation files
206+ paths: |
207+ README.md
208+ docs/**/*.md
209+ .github/workflows/*.md
210+ actions/**/README.md
211+
212+ # ❌ BAD: Too broad, includes non-documentation files
213+ paths: |
214+ docs/
215+ .github/workflows/
216+ actions/
217+ ` ` `
218+
219+ **Best practices**:
220+
221+ - Always include file extensions (`.md`, `.mdx`)
222+ - Use `**/*.md` for recursive matching in directories
223+ - Explicitly list root-level files like `README.md`
224+ - Avoid matching entire directories without file patterns
225+
226+ # ## Workflow Architecture
227+
228+ The sync-docs system uses a two-workflow architecture :
229+
230+ ` ` ` txt
231+ ┌─────────────────────────────────────────────────┐
232+ │ Your Project Repository │
233+ │ ┌───────────────────────────────────────────┐ │
234+ │ │ Step 1: Prepare Documentation │ │
235+ │ │ - Collect Markdown files │ │
236+ │ │ - Add source metadata │ │
237+ │ │ - Upload as artifact │ │
238+ │ └─────────────┬─────────────────────────────┘ │
239+ │ │ │
240+ │ ┌─────────────▼─────────────────────────────┐ │
241+ │ │ Step 2: Dispatch (this workflow) │ │
242+ │ │ - Send repository_dispatch event │ │
243+ │ │ - Reference uploaded artifact │ │
244+ │ └───────────────────────────────────────────┘ │
245+ └─────────────────┬───────────────────────────────┘
246+ │ repository_dispatch
247+ ▼
248+ ┌─────────────────────────────────────────────────┐
249+ │ hoverkraft-tech/public-docs │
250+ │ ┌───────────────────────────────────────────┐ │
251+ │ │ Step 3: Receiver Workflow │ │
252+ │ │ - Download artifact from source repo │ │
253+ │ │ - Extract and inject docs │ │
254+ │ │ - Create and auto-merge PR │ │
255+ │ │ - Trigger build and deployment │ │
256+ │ └───────────────────────────────────────────┘ │
257+ └─────────────────────────────────────────────────┘
258+ ` ` `
259+
260+ # # Best Practices
261+
262+ # ## Documentation Content
176263
1772641. **Keep documentation with code** : Store docs in the same repository as your code
1782652. **Use standard structure** : Place documentation in a `docs/` directory
@@ -271,102 +358,6 @@ After setting up sync-docs:
271358 - Verify deployment to GitHub Pages succeeds
272359 - Visit documentation portal to see live changes
273360
274- # # Workflow Architecture
275-
276- # ## Understanding the Two-Step Process
277-
278- The sync-docs system uses a two-workflow architecture :
279-
280- ` ` ` txt
281- ┌─────────────────────────────────────────────────┐
282- │ Your Project Repository │
283- │ ┌───────────────────────────────────────────┐ │
284- │ │ Step 1: Prepare Documentation │ │
285- │ │ - Collect Markdown files │ │
286- │ │ - Add source metadata │ │
287- │ │ - Upload as artifact │ │
288- │ └─────────────┬─────────────────────────────┘ │
289- │ │ │
290- │ ┌─────────────▼─────────────────────────────┐ │
291- │ │ Step 2: Dispatch (this workflow) │ │
292- │ │ - Send repository_dispatch event │ │
293- │ │ - Reference uploaded artifact │ │
294- │ └───────────────────────────────────────────┘ │
295- └─────────────────┬───────────────────────────────┘
296- │ repository_dispatch
297- ▼
298- ┌─────────────────────────────────────────────────┐
299- │ hoverkraft-tech/public-docs │
300- │ ┌───────────────────────────────────────────┐ │
301- │ │ Step 3: Receiver Workflow │ │
302- │ │ - Download artifact from source repo │ │
303- │ │ - Extract and inject docs │ │
304- │ │ - Create and auto-merge PR │ │
305- │ │ - Trigger build and deployment │ │
306- │ └───────────────────────────────────────────┘ │
307- └─────────────────────────────────────────────────┘
308- ` ` `
309-
310- # ## Preparing Documentation Artifact
311-
312- Before calling this workflow, you must prepare and upload a documentation artifact. Use the [prepare-docs action](./../actions/prepare-docs/README.md) :
313-
314- ` ` ` yaml
315- jobs:
316- prepare-docs:
317- name: Prepare Documentation
318- runs-on: ubuntu-latest
319- permissions:
320- contents: read
321- steps:
322- - uses: actions/checkout@v4
323-
324- - name: Prepare documentation
325- id: prepare-docs
326- uses: hoverkraft-tech/public-docs/.github/actions/prepare-docs@18facec04f2945f4d66d510e8a06568497b73c54 # 0.1.0
327- with:
328- paths: |
329- README.md
330- docs/**/*.md
331- .github/workflows/*.md
332-
333- sync-docs:
334- name: Sync Documentation
335- needs: prepare-docs
336- uses: hoverkraft-tech/public-docs/.github/workflows/sync-docs-dispatcher.yml@18facec04f2945f4d66d510e8a06568497b73c54 # 0.1.0
337- with:
338- github-app-id: ${{ vars.PUBLIC_DOCS_APP_ID }}
339- artifact-id: docs
340- secrets:
341- github-app-key: ${{ secrets.PUBLIC_DOCS_APP_PRIVATE_KEY }}
342- ` ` `
343-
344- # ## Path Pattern Recommendations
345-
346- Use **specific glob patterns** for Markdown files only :
347-
348- ` ` ` yaml
349- # ✅ GOOD: Specific patterns for documentation files
350- paths: |
351- README.md
352- docs/**/*.md
353- .github/workflows/*.md
354- actions/**/README.md
355-
356- # ❌ BAD: Too broad, includes non-documentation files
357- paths: |
358- docs/
359- .github/workflows/
360- actions/
361- ` ` `
362-
363- **Best practices**:
364-
365- - Always include file extensions (`.md`, `.mdx`)
366- - Use `**/*.md` for recursive matching in directories
367- - Explicitly list root-level files like `README.md`
368- - Avoid matching entire directories without file patterns
369-
370361<!-- inputs:start -->
371362
372363# # Inputs
0 commit comments