generateReadme generates a README.md file
(actionDir string, metadata *ActionMetadata)
| 370 | |
| 371 | // generateReadme generates a README.md file |
| 372 | func generateReadme(actionDir string, metadata *ActionMetadata) error { |
| 373 | generateActionMetadataLog.Printf("Generating README.md: action=%s, deps=%d", metadata.ActionName, len(metadata.Dependencies)) |
| 374 | var content strings.Builder |
| 375 | |
| 376 | fmt.Fprintf(&content, "# %s\n\n", metadata.Name) |
| 377 | fmt.Fprintf(&content, "%s\n\n", metadata.Description) |
| 378 | |
| 379 | content.WriteString("## Overview\n\n") |
| 380 | fmt.Fprintf(&content, "This action is generated from `pkg/workflow/js/%s` and provides functionality ", metadata.Filename) |
| 381 | content.WriteString("for GitHub Agentic Workflows.\n\n") |
| 382 | |
| 383 | // Usage section |
| 384 | content.WriteString("## Usage\n\n") |
| 385 | content.WriteString("```yaml\n") |
| 386 | fmt.Fprintf(&content, "- uses: ./actions/%s\n", metadata.ActionName) |
| 387 | if len(metadata.Inputs) > 0 { |
| 388 | content.WriteString(" with:\n") |
| 389 | for _, input := range metadata.Inputs { |
| 390 | fmt.Fprintf(&content, " %s: 'value' # %s\n", input.Name, input.Description) |
| 391 | } |
| 392 | } |
| 393 | content.WriteString("```\n\n") |
| 394 | |
| 395 | // Inputs section |
| 396 | if len(metadata.Inputs) > 0 { |
| 397 | content.WriteString("## Inputs\n\n") |
| 398 | for _, input := range metadata.Inputs { |
| 399 | fmt.Fprintf(&content, "### `%s`\n\n", input.Name) |
| 400 | fmt.Fprintf(&content, "**Description**: %s\n\n", input.Description) |
| 401 | fmt.Fprintf(&content, "**Required**: %t\n\n", input.Required) |
| 402 | if input.Default != "" { |
| 403 | fmt.Fprintf(&content, "**Default**: `%s`\n\n", input.Default) |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | // Outputs section |
| 409 | if len(metadata.Outputs) > 0 { |
| 410 | content.WriteString("## Outputs\n\n") |
| 411 | for _, output := range metadata.Outputs { |
| 412 | fmt.Fprintf(&content, "### `%s`\n\n", output.Name) |
| 413 | fmt.Fprintf(&content, "**Description**: %s\n\n", output.Description) |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | // Dependencies section |
| 418 | if len(metadata.Dependencies) > 0 { |
| 419 | content.WriteString("## Dependencies\n\n") |
| 420 | content.WriteString("This action depends on the following JavaScript modules:\n\n") |
| 421 | for _, dep := range metadata.Dependencies { |
| 422 | fmt.Fprintf(&content, "- `%s`\n", dep) |
| 423 | } |
| 424 | content.WriteString("\n") |
| 425 | } |
| 426 | |
| 427 | // Development section |
| 428 | content.WriteString("## Development\n\n") |
| 429 | content.WriteString("### Building\n\n") |