|
1 | | -# CodeBoarding GitHub Action |
| 1 | +# CodeBoarding [Diagram-First Documentation] |
2 | 2 |
|
3 | | -A composite GitHub Action that fetches documentation files from a CodeBoarding service and saves them as markdown files in your repository. |
| 3 | +[](https://github.com/marketplace/actions/codeboarding-diagram-first-documentation) |
4 | 4 |
|
5 | | -## Features |
6 | | - |
7 | | -- 🚀 **Simple Integration**: Easy to use composite action |
8 | | -- 📁 **Flexible Output**: Configurable output directory (default: `.codeboarding`) |
9 | | -- 🔄 **Smart Processing**: Automatically adds `.md` extension if needed |
10 | | -- 📊 **Detailed Outputs**: Provides information about created files and changes |
11 | | -- 🛡️ **Error Handling**: Robust error handling for API calls and JSON parsing |
12 | | - |
13 | | -## How it works |
14 | | - |
15 | | -1. The action determines the repository URL (current repo or provided) |
16 | | -2. Calls your CodeBoarding endpoint with the repository URL as a query parameter |
17 | | -3. Receives a JSON response with files and their content |
18 | | -4. Creates/updates files in the specified output directory with `.md` extension |
19 | | -5. Provides outputs that can be used by subsequent workflow steps |
| 5 | +Generates diagram-first visualizations of your codebase using static analysis and large language models. |
20 | 6 |
|
21 | 7 | ## Usage |
22 | 8 |
|
23 | | -### Basic Usage |
24 | | - |
25 | | -```yaml |
26 | | -- name: Fetch CodeBoarding Documentation |
27 | | - uses: your-username/codeboarding-action@v1 |
28 | | - with: |
29 | | - endpoint_url: 'https://your-api-endpoint.com/generate_docs' |
30 | | -``` |
31 | | -
|
32 | | -### Advanced Usage |
33 | | -
|
34 | | -```yaml |
35 | | -- name: Fetch CodeBoarding Documentation |
36 | | - id: codeboarding |
37 | | - uses: your-username/codeboarding-action@v1 |
38 | | - with: |
39 | | - endpoint_url: ${{ vars.CODEBOARDING_ENDPOINT }} |
40 | | - repository_url: 'https://github.com/owner/repo' # Optional: defaults to current repo |
41 | | - output_directory: 'docs/generated' # Optional: defaults to .codeboarding |
42 | | - |
43 | | -- name: Check results |
44 | | - run: | |
45 | | - echo "Files created: ${{ steps.codeboarding.outputs.files_created }}" |
46 | | - echo "Has changes: ${{ steps.codeboarding.outputs.has_changes }}" |
47 | | -``` |
48 | | -
|
49 | | -### Complete Workflow with PR Creation |
50 | | -
|
51 | 9 | ```yaml |
52 | | -name: Update Documentation |
53 | | - |
| 10 | +name: Generate Documentation |
54 | 11 | on: |
55 | | - schedule: |
56 | | - - cron: '0 2 * * *' # Daily at 2 AM |
57 | | - workflow_dispatch: |
| 12 | + push: |
| 13 | + branches: [ main ] |
| 14 | + pull_request: |
| 15 | + branches: [ main ] |
58 | 16 |
|
59 | 17 | jobs: |
60 | | - update-docs: |
| 18 | + documentation: |
61 | 19 | runs-on: ubuntu-latest |
62 | | - permissions: |
63 | | - contents: write |
64 | | - pull-requests: write |
65 | | - |
66 | 20 | steps: |
67 | | - - uses: actions/checkout@v4 |
68 | | - |
69 | | - - name: Fetch Documentation |
70 | | - id: docs |
71 | | - uses: your-username/codeboarding-action@v1 |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Generate Documentation |
| 25 | + uses: your-username/CodeBoarding-GHAction@v1 |
72 | 26 | with: |
73 | | - endpoint_url: ${{ vars.CODEBOARDING_ENDPOINT }} |
74 | | - |
75 | | - - name: Create Pull Request |
76 | | - if: steps.docs.outputs.has_changes == 'true' |
77 | | - uses: peter-evans/create-pull-request@v5 |
| 27 | + repository_url: ${{ github.server_url }}/${{ github.repository }} |
| 28 | + output_directory: '.codeboarding' |
| 29 | + |
| 30 | + - name: Upload Documentation |
| 31 | + uses: actions/upload-artifact@v4 |
78 | 32 | with: |
79 | | - token: ${{ secrets.GITHUB_TOKEN }} |
80 | | - commit-message: "docs: update codeboarding documentation" |
81 | | - title: "📚 Documentation Update" |
82 | | - body: | |
83 | | - Updated ${{ steps.docs.outputs.files_created }} documentation files. |
84 | | - branch: docs/update |
| 33 | + name: documentation |
| 34 | + path: .codeboarding/ |
85 | 35 | ``` |
86 | 36 |
|
87 | 37 | ## Inputs |
88 | 38 |
|
89 | 39 | | Input | Description | Required | Default | |
90 | 40 | |-------|-------------|----------|---------| |
91 | | -| `endpoint_url` | URL of the CodeBoarding service endpoint | Yes | - | |
92 | | -| `repository_url` | Repository URL to analyze (defaults to current repo) | No | Current repository | |
93 | | -| `output_directory` | Directory where files will be saved | No | `.codeboarding` | |
| 41 | +| `repository_url` | Repository URL to fetch documentation for | Yes | - | |
| 42 | +| `output_directory` | Directory where documentation files will be saved | No | `.codeboarding` | |
94 | 43 |
|
95 | 44 | ## Outputs |
96 | 45 |
|
97 | 46 | | Output | Description | |
98 | 47 | |--------|-------------| |
99 | | -| `files_created` | Number of files created/updated | |
| 48 | +| `files_created` | Number of files created | |
100 | 49 | | `output_directory` | Directory where files were saved | |
101 | | -| `has_changes` | Whether any files were created or changed (`true`/`false`) | |
102 | | - |
103 | | -## Setup |
104 | | - |
105 | | -### 1. Configure the endpoint URL |
106 | | - |
107 | | -You have several options to configure the endpoint URL: |
108 | | - |
109 | | -**Option A: Using repository variables (recommended)** |
110 | | -1. Go to your repository Settings > Secrets and variables > Actions |
111 | | -2. In the "Variables" tab, create a new variable: |
112 | | - - Name: `CODEBOARDING_ENDPOINT` |
113 | | - - Value: `https://your-api-endpoint.com/generate_docs` (replace with your actual endpoint) |
114 | | - |
115 | | -**Option B: Pass directly in workflow** |
116 | | -```yaml |
117 | | -- uses: your-username/codeboarding-action@v1 |
118 | | - with: |
119 | | - endpoint_url: 'https://your-api-endpoint.com/generate_docs' |
120 | | -``` |
121 | | - |
122 | | -### 2. Expected API Response Format |
123 | | - |
124 | | -Your endpoint should return a JSON response in this format: |
125 | | - |
126 | | -```json |
127 | | -{ |
128 | | - "repository": "owner/repo-name", |
129 | | - "files": { |
130 | | - "getting-started": "# Getting Started\n\nThis is the content...", |
131 | | - "api-reference": "# API Reference\n\nAPI documentation...", |
132 | | - "troubleshooting": "# Troubleshooting\n\nCommon issues..." |
133 | | - } |
134 | | -} |
135 | | -``` |
136 | | - |
137 | | -- `repository`: The repository name (informational) |
138 | | -- `files`: A dictionary where keys are filenames and values are the markdown content |
139 | | - |
140 | | -### 2. Expected API Response Format |
141 | | - |
142 | | -Your endpoint should return a JSON response in this format: |
143 | | - |
144 | | -```json |
145 | | -{ |
146 | | - "repository": "owner/repo-name", |
147 | | - "files": { |
148 | | - "getting-started": "# Getting Started\n\nThis is the content...", |
149 | | - "api-reference": "# API Reference\n\nAPI documentation...", |
150 | | - "troubleshooting": "# Troubleshooting\n\nCommon issues..." |
151 | | - } |
152 | | -} |
153 | | -``` |
154 | | - |
155 | | -- `repository`: The repository name (informational, optional) |
156 | | -- `files`: A dictionary where keys are filenames and values are the markdown content |
157 | | - |
158 | | -### 3. Permissions |
159 | | - |
160 | | -When using this action in workflows that create PRs or commits, ensure your workflow has the necessary permissions: |
161 | | - |
162 | | -```yaml |
163 | | -jobs: |
164 | | - your-job: |
165 | | - permissions: |
166 | | - contents: write # For committing files |
167 | | - pull-requests: write # For creating PRs |
168 | | -``` |
169 | | - |
170 | | -## Design Philosophy |
171 | | - |
172 | | -This composite action follows the **single responsibility principle**: |
173 | | - |
174 | | -- ✅ **Does one thing well**: Fetches and saves documentation files |
175 | | -- ✅ **Flexible output**: You decide what to do with the files (commit, PR, etc.) |
176 | | -- ✅ **Composable**: Can be combined with other actions easily |
177 | | -- ✅ **Testable**: Clear inputs and outputs make testing straightforward |
178 | | - |
179 | | -## Examples |
180 | | - |
181 | | -### Example 1: Save to Custom Directory |
182 | | - |
183 | | -```yaml |
184 | | -- uses: your-username/codeboarding-action@v1 |
185 | | - with: |
186 | | - endpoint_url: ${{ vars.CODEBOARDING_ENDPOINT }} |
187 | | - output_directory: 'documentation/auto-generated' |
188 | | -``` |
189 | | - |
190 | | -### Example 2: Analyze Different Repository |
191 | | - |
192 | | -```yaml |
193 | | -- uses: your-username/codeboarding-action@v1 |
194 | | - with: |
195 | | - endpoint_url: ${{ vars.CODEBOARDING_ENDPOINT }} |
196 | | - repository_url: 'https://github.com/other-org/other-repo' |
197 | | -``` |
198 | | - |
199 | | -### Example 3: Conditional Processing |
200 | | - |
201 | | -```yaml |
202 | | -- name: Generate docs |
203 | | - id: docs |
204 | | - uses: your-username/codeboarding-action@v1 |
205 | | - with: |
206 | | - endpoint_url: ${{ vars.CODEBOARDING_ENDPOINT }} |
207 | | -
|
208 | | -- name: Only proceed if files were created |
209 | | - if: steps.docs.outputs.has_changes == 'true' |
210 | | - run: | |
211 | | - echo "Processing ${{ steps.docs.outputs.files_created }} new files..." |
212 | | - # Your custom logic here |
213 | | -``` |
214 | | - |
215 | | -## Troubleshooting |
216 | | - |
217 | | -### Common Issues |
218 | | - |
219 | | -1. **API endpoint returns non-200 status** |
220 | | - - Check that your endpoint URL is correct |
221 | | - - Verify the endpoint is accessible from GitHub Actions runners |
222 | | - - Check endpoint logs for errors |
223 | | - |
224 | | -2. **Invalid JSON response** |
225 | | - - Ensure your endpoint returns valid JSON |
226 | | - - Check that the response includes the expected `files` key |
227 | | - |
228 | | -3. **No files created** |
229 | | - - Verify the API response contains a `files` object with content |
230 | | - - Check the action logs for debugging information |
231 | | - |
232 | | -### Debug Mode |
233 | | - |
234 | | -The action includes extensive logging. Check the action logs in your workflow runs for detailed information about: |
235 | | -- API request and response |
236 | | -- JSON parsing results |
237 | | -- File creation process |
238 | | -- `contents: write` - to create commits |
239 | | -- `pull-requests: write` - to create pull requests |
240 | | - |
241 | | -## Usage |
242 | | - |
243 | | -### Automatic execution |
244 | | -- The action runs daily at 2 AM UTC |
245 | | -- Scheduled runs can be configured by modifying the cron expression in the workflow |
246 | | - |
247 | | -### Manual execution |
248 | | -1. Go to Actions tab in your repository |
249 | | -2. Select "Documentation Update" workflow |
250 | | -3. Click "Run workflow" |
251 | | - |
252 | | -## File handling |
253 | | - |
254 | | -- Files are created in the `.codeboarding` directory |
255 | | -- All files automatically get `.md` extension if not already present |
256 | | -- Existing files are overwritten with new content |
257 | | -- Only creates a PR if there are actual changes |
258 | | - |
259 | | -## Pull Request behavior |
260 | | - |
261 | | -- PR title: "doc update" |
262 | | -- Branch name: `docs/codeboarding-update` |
263 | | -- Automatically deletes the branch after PR is merged/closed |
264 | | -- Only creates PR if there are changes to commit |
265 | | - |
266 | | -## Troubleshooting |
267 | | - |
268 | | -### API call fails |
269 | | -- Check that your endpoint URL is correct |
270 | | -- Verify the endpoint is accessible from GitHub Actions runners |
271 | | -- Check the Actions logs for the exact error message |
| 50 | +| `has_changes` | Whether any files were created or changed | |
272 | 51 |
|
273 | | -### No PR created |
274 | | -- This means no changes were detected |
275 | | -- The API response might be identical to existing files |
276 | | -- Check the "Check for changes" step in the workflow logs |
| 52 | +## License |
277 | 53 |
|
278 | | -### Invalid JSON response |
279 | | -- Verify your endpoint returns valid JSON |
280 | | -- Check the response format matches the expected structure |
281 | | -- Review the API response in the workflow logs |
| 54 | +MIT License - see [LICENSE](LICENSE) file for details. |
0 commit comments