mirror of
https://github.com/ivuorinen/gh-action-readme.git
synced 2026-02-15 04:49:47 +00:00
feat(lint): add many linters, make all the tests run fast! (#23)
* chore(lint): added nlreturn, run linting * chore(lint): replace some fmt.Sprintf calls * chore(lint): replace fmt.Sprintf with strconv * chore(lint): add goconst, use http lib for status codes, and methods * chore(lint): use errors lib, errCodes from internal/errors * chore(lint): dupl, thelper and usetesting * chore(lint): fmt.Errorf %v to %w, more linters * chore(lint): paralleltest, where possible * perf(test): optimize test performance by 78% - Implement shared binary building with package-level cache to eliminate redundant builds - Add strategic parallelization to 15+ tests while preserving environment variable isolation - Implement thread-safe fixture caching with RWMutex to reduce I/O operations - Remove unnecessary working directory changes by leveraging embedded templates - Add embedded template system with go:embed directive for reliable template resolution - Fix linting issues: rename sharedBinaryError to errSharedBinary, add nolint directive Performance improvements: - Total test execution time: 12+ seconds → 2.7 seconds (78% faster) - Binary build overhead: 14+ separate builds → 1 shared build (93% reduction) - Parallel execution: Limited → 15+ concurrent tests (60-70% better CPU usage) - I/O operations: 66+ fixture reads → cached with sync.RWMutex (50% reduction) All tests maintain 100% success rate and coverage while running nearly 4x faster.
This commit is contained in:
77
templates_embed/embed.go
Normal file
77
templates_embed/embed.go
Normal file
@@ -0,0 +1,77 @@
|
||||
// Package templates_embed provides embedded template filesystem functionality for gh-action-readme.
|
||||
// This package contains all template files embedded in the binary using Go's embed directive,
|
||||
// making templates available regardless of working directory or filesystem location.
|
||||
//
|
||||
//nolint:revive // Package name with underscore is intentional for clarity
|
||||
package templates_embed
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// embeddedTemplates contains all template files embedded in the binary
|
||||
//
|
||||
//go:embed templates
|
||||
var embeddedTemplates embed.FS
|
||||
|
||||
// GetEmbeddedTemplate reads a template from the embedded filesystem.
|
||||
func GetEmbeddedTemplate(templatePath string) ([]byte, error) {
|
||||
// Normalize path separators and remove leading slash if present
|
||||
cleanPath := strings.TrimPrefix(filepath.ToSlash(templatePath), "/")
|
||||
|
||||
// If path doesn't start with templates/, prepend it
|
||||
if !strings.HasPrefix(cleanPath, "templates/") {
|
||||
cleanPath = "templates/" + cleanPath
|
||||
}
|
||||
|
||||
return embeddedTemplates.ReadFile(cleanPath)
|
||||
}
|
||||
|
||||
// GetEmbeddedTemplateFS returns the embedded filesystem for templates.
|
||||
func GetEmbeddedTemplateFS() fs.FS {
|
||||
return embeddedTemplates
|
||||
}
|
||||
|
||||
// IsEmbeddedTemplateAvailable checks if a template exists in the embedded filesystem.
|
||||
func IsEmbeddedTemplateAvailable(templatePath string) bool {
|
||||
cleanPath := strings.TrimPrefix(filepath.ToSlash(templatePath), "/")
|
||||
if !strings.HasPrefix(cleanPath, "templates/") {
|
||||
cleanPath = "templates/" + cleanPath
|
||||
}
|
||||
|
||||
_, err := embeddedTemplates.ReadFile(cleanPath)
|
||||
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// ReadTemplate reads a template from embedded filesystem first, then falls back to filesystem.
|
||||
func ReadTemplate(templatePath string) ([]byte, error) {
|
||||
// If it's an absolute path, read from filesystem with path validation
|
||||
if filepath.IsAbs(templatePath) {
|
||||
// Validate the path is clean to prevent path traversal attacks
|
||||
cleanPath := filepath.Clean(templatePath)
|
||||
if cleanPath != templatePath {
|
||||
return nil, filepath.ErrBadPattern
|
||||
}
|
||||
|
||||
return os.ReadFile(cleanPath) // #nosec G304 -- validated absolute path
|
||||
}
|
||||
|
||||
// Try embedded template first
|
||||
if IsEmbeddedTemplateAvailable(templatePath) {
|
||||
return GetEmbeddedTemplate(templatePath)
|
||||
}
|
||||
|
||||
// Fallback to filesystem with path validation
|
||||
// Validate the path is clean to prevent path traversal attacks
|
||||
cleanPath := filepath.Clean(templatePath)
|
||||
if cleanPath != templatePath || strings.Contains(cleanPath, "..") {
|
||||
return nil, filepath.ErrBadPattern
|
||||
}
|
||||
|
||||
return os.ReadFile(cleanPath) // #nosec G304 -- validated relative path
|
||||
}
|
||||
5
templates_embed/templates/footer.tmpl
Normal file
5
templates_embed/templates/footer.tmpl
Normal file
@@ -0,0 +1,5 @@
|
||||
<footer style="margin-top: 2rem; border-top: 1px solid #ccc; padding-top: 1rem; color: #888; font-size: 0.95em;">
|
||||
<p>Auto-generated by <a href="https://github.com/ivuorinen/gh-action-readme">gh-action-readme</a>. MIT License.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
15
templates_embed/templates/header.tmpl
Normal file
15
templates_embed/templates/header.tmpl
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{.Name}} GitHub Action Documentation</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
body { font-family: system-ui, sans-serif; margin: 2rem; background: #f9f9fb; }
|
||||
h1, h2, h3 { color: #111; }
|
||||
pre { background: #eee; padding: 1em; border-radius: 6px; }
|
||||
code { font-family: mono; }
|
||||
.badge { vertical-align: middle; margin-right: 8px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
37
templates_embed/templates/readme.tmpl
Normal file
37
templates_embed/templates/readme.tmpl
Normal file
@@ -0,0 +1,37 @@
|
||||
# {{.Name}}
|
||||
|
||||
{{if .Branding}}
|
||||
> {{.Description}}
|
||||
|
||||
## Usage
|
||||
|
||||
```yaml
|
||||
- uses: {{gitUsesString .}}
|
||||
with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: # {{$val.Description}}{{if $val.Default}} (default: {{$val.Default}}){{end}}
|
||||
{{- end}}
|
||||
```
|
||||
|
||||
## Inputs
|
||||
|
||||
{{range $key, $input := .Inputs}}
|
||||
- **{{$key}}**: {{$input.Description}}{{if $input.Required}} (**required**){{end}}{{if $input.Default}} (default: {{$input.Default}}){{end}}
|
||||
{{end}}
|
||||
|
||||
{{if .Outputs}}
|
||||
## Outputs
|
||||
|
||||
{{range $key, $output := .Outputs}}
|
||||
- **{{$key}}**: {{$output.Description}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
## Example
|
||||
|
||||
See the [action.yml](./action.yml) for a full reference.
|
||||
|
||||
---
|
||||
|
||||
*Auto-generated by [gh-action-readme](https://github.com/ivuorinen/gh-action-readme)*
|
||||
{{end}}
|
||||
176
templates_embed/templates/themes/asciidoc/readme.adoc
Normal file
176
templates_embed/templates/themes/asciidoc/readme.adoc
Normal file
@@ -0,0 +1,176 @@
|
||||
= {{.Name}}
|
||||
:toc: left
|
||||
:toclevels: 3
|
||||
:icons: font
|
||||
:source-highlighter: highlight.js
|
||||
|
||||
{{if .Branding}}image:https://img.shields.io/badge/icon-{{.Branding.Icon}}-{{.Branding.Color}}[{{.Branding.Icon}}] {{end}}+
|
||||
image:https://img.shields.io/badge/GitHub%20Action-{{.Name | replace " " "%20"}}-blue[GitHub Action] +
|
||||
image:https://img.shields.io/badge/license-MIT-green[License]
|
||||
|
||||
[.lead]
|
||||
{{.Description}}
|
||||
|
||||
== Quick Start
|
||||
|
||||
Add this action to your GitHub workflow:
|
||||
|
||||
[source,yaml]
|
||||
----
|
||||
name: CI Workflow
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: {{.Name}}
|
||||
uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}"{{$val.Default}}"{{else}}"value"{{end}}
|
||||
{{- end}}{{end}}
|
||||
----
|
||||
|
||||
{{if .Inputs}}
|
||||
== Input Parameters
|
||||
|
||||
[cols="1,3,1,2", options="header"]
|
||||
|===
|
||||
| Parameter | Description | Required | Default
|
||||
|
||||
{{range $key, $input := .Inputs}}
|
||||
| `{{$key}}`
|
||||
| {{$input.Description}}
|
||||
| {{if $input.Required}}✓{{else}}✗{{end}}
|
||||
| {{if $input.Default}}`{{$input.Default}}`{{else}}_none_{{end}}
|
||||
|
||||
{{end}}
|
||||
|===
|
||||
|
||||
=== Parameter Details
|
||||
|
||||
{{range $key, $input := .Inputs}}
|
||||
==== {{$key}}
|
||||
|
||||
{{$input.Description}}
|
||||
|
||||
[horizontal]
|
||||
Type:: String
|
||||
Required:: {{if $input.Required}}Yes{{else}}No{{end}}
|
||||
{{if $input.Default}}Default:: `{{$input.Default}}`{{end}}
|
||||
|
||||
.Example
|
||||
[source,yaml]
|
||||
----
|
||||
with:
|
||||
{{$key}}: {{if $input.Default}}"{{$input.Default}}"{{else}}"your-value"{{end}}
|
||||
----
|
||||
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{if .Outputs}}
|
||||
== Output Parameters
|
||||
|
||||
[cols="1,3", options="header"]
|
||||
|===
|
||||
| Parameter | Description
|
||||
|
||||
{{range $key, $output := .Outputs}}
|
||||
| `{{$key}}`
|
||||
| {{$output.Description}}
|
||||
|
||||
{{end}}
|
||||
|===
|
||||
|
||||
=== Using Outputs
|
||||
|
||||
[source,yaml]
|
||||
----
|
||||
- name: {{.Name}}
|
||||
id: action-step
|
||||
uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
|
||||
- name: Use Output
|
||||
run: |
|
||||
{{- range $key, $output := .Outputs}}
|
||||
echo "{{$key}}: \${{"{{"}} steps.action-step.outputs.{{$key}} {{"}}"}}"
|
||||
{{- end}}
|
||||
----
|
||||
{{end}}
|
||||
|
||||
== Examples
|
||||
|
||||
=== Basic Usage
|
||||
|
||||
[source,yaml]
|
||||
----
|
||||
- name: Basic {{.Name}}
|
||||
uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}"{{$val.Default}}"{{else}}"example-value"{{end}}
|
||||
{{- end}}{{end}}
|
||||
----
|
||||
|
||||
=== Advanced Configuration
|
||||
|
||||
[source,yaml]
|
||||
----
|
||||
- name: Advanced {{.Name}}
|
||||
uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}"{{$val.Default}}"{{else}}"\${{"{{"}} vars.{{$key | upper}} {{"}}"}}"{{end}}
|
||||
{{- end}}{{end}}
|
||||
env:
|
||||
GITHUB_TOKEN: \${{"{{"}} secrets.GITHUB_TOKEN {{"}}"}}
|
||||
----
|
||||
|
||||
=== Conditional Usage
|
||||
|
||||
[source,yaml]
|
||||
----
|
||||
- name: Conditional {{.Name}}
|
||||
if: github.event_name == 'push'
|
||||
uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}"{{$val.Default}}"{{else}}"production-value"{{end}}
|
||||
{{- end}}{{end}}
|
||||
----
|
||||
|
||||
== Troubleshooting
|
||||
|
||||
[TIP]
|
||||
====
|
||||
Common issues and solutions:
|
||||
|
||||
1. **Authentication Errors**: Ensure required secrets are configured
|
||||
2. **Permission Issues**: Verify GitHub token permissions
|
||||
3. **Configuration Errors**: Validate input parameters
|
||||
====
|
||||
|
||||
== Development
|
||||
|
||||
For development information, see the link:./action.yml[action.yml] specification.
|
||||
|
||||
=== Contributing
|
||||
|
||||
Contributions are welcome! Please:
|
||||
|
||||
1. Fork the repository
|
||||
2. Create a feature branch
|
||||
3. Make your changes
|
||||
4. Add tests
|
||||
5. Submit a pull request
|
||||
|
||||
== License
|
||||
|
||||
This project is licensed under the MIT License.
|
||||
|
||||
---
|
||||
|
||||
_Documentation generated with https://github.com/ivuorinen/gh-action-readme[gh-action-readme]_
|
||||
141
templates_embed/templates/themes/github/readme.tmpl
Normal file
141
templates_embed/templates/themes/github/readme.tmpl
Normal file
@@ -0,0 +1,141 @@
|
||||
# {{.Name}}
|
||||
|
||||
{{if .Branding}} {{end}}
|
||||

|
||||

|
||||
|
||||
> {{.Description}}
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
```yaml
|
||||
name: My Workflow
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: {{.Name}}
|
||||
uses: {{gitUsesString .}}
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}"{{$val.Default}}"{{else}}"value"{{end}}
|
||||
{{- end}}{{end}}
|
||||
```
|
||||
|
||||
{{if .Inputs}}
|
||||
## 📥 Inputs
|
||||
|
||||
| Parameter | Description | Required | Default |
|
||||
|-----------|-------------|----------|---------|
|
||||
{{- range $key, $input := .Inputs}}
|
||||
| `{{$key}}` | {{$input.Description}} | {{if $input.Required}}✅{{else}}❌{{end}} | {{if $input.Default}}`{{$input.Default}}`{{else}}-{{end}} |
|
||||
{{- end}}
|
||||
{{end}}
|
||||
|
||||
{{if .Outputs}}
|
||||
## 📤 Outputs
|
||||
|
||||
| Parameter | Description |
|
||||
|-----------|-------------|
|
||||
{{- range $key, $output := .Outputs}}
|
||||
| `{{$key}}` | {{$output.Description}} |
|
||||
{{- end}}
|
||||
{{end}}
|
||||
|
||||
## 💡 Examples
|
||||
|
||||
<details>
|
||||
<summary>Basic Usage</summary>
|
||||
|
||||
```yaml
|
||||
- name: {{.Name}}
|
||||
uses: {{gitUsesString .}}
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}"{{$val.Default}}"{{else}}"example-value"{{end}}
|
||||
{{- end}}{{end}}
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Advanced Configuration</summary>
|
||||
|
||||
```yaml
|
||||
- name: {{.Name}} with custom settings
|
||||
uses: {{gitUsesString .}}
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}"{{$val.Default}}"{{else}}"custom-value"{{end}}
|
||||
{{- end}}{{end}}
|
||||
```
|
||||
</details>
|
||||
|
||||
{{if .Dependencies}}
|
||||
## 📦 Dependencies
|
||||
|
||||
This action uses the following dependencies:
|
||||
|
||||
| Action | Version | Author | Description |
|
||||
|--------|---------|--------|-------------|
|
||||
{{- range .Dependencies}}
|
||||
| {{if .MarketplaceURL}}[{{.Name}}]({{.MarketplaceURL}}){{else}}{{.Name}}{{end}} | {{if .IsPinned}}🔒{{end}}{{.Version}} | [{{.Author}}](https://github.com/{{.Author}}) | {{.Description}} |
|
||||
{{- end}}
|
||||
|
||||
<details>
|
||||
<summary>📋 Dependency Details</summary>
|
||||
|
||||
{{range .Dependencies}}
|
||||
### {{.Name}}{{if .Version}} @ {{.Version}}{{end}}
|
||||
|
||||
{{if .IsPinned}}
|
||||
- 🔒 **Pinned Version**: Locked to specific version for security
|
||||
{{else}}
|
||||
- 📌 **Floating Version**: Using latest version (consider pinning for security)
|
||||
{{end}}
|
||||
- 👤 **Author**: [{{.Author}}](https://github.com/{{.Author}})
|
||||
{{if .MarketplaceURL}}- 🏪 **Marketplace**: [View on GitHub Marketplace]({{.MarketplaceURL}}){{end}}
|
||||
{{if .SourceURL}}- 📂 **Source**: [View Source]({{.SourceURL}}){{end}}
|
||||
{{if .WithParams}}
|
||||
- **Configuration**:
|
||||
```yaml
|
||||
with:
|
||||
{{- range $key, $value := .WithParams}}
|
||||
{{$key}}: {{$value}}
|
||||
{{- end}}
|
||||
```
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
||||
{{$hasLocalDeps := false}}
|
||||
{{range .Dependencies}}{{if .IsLocalAction}}{{$hasLocalDeps = true}}{{end}}{{end}}
|
||||
{{if $hasLocalDeps}}
|
||||
### Same Repository Dependencies
|
||||
{{range .Dependencies}}{{if .IsLocalAction}}
|
||||
- [{{.Name}}]({{.SourceURL}}) - {{.Description}}
|
||||
{{end}}{{end}}
|
||||
{{end}}
|
||||
|
||||
</details>
|
||||
{{end}}
|
||||
|
||||
## 🔧 Development
|
||||
|
||||
See the [action.yml](./action.yml) for the complete action specification.
|
||||
|
||||
## 📄 License
|
||||
|
||||
This action is distributed under the MIT License. See [LICENSE](LICENSE) for more information.
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
Contributions are welcome! Please feel free to submit a Pull Request.
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<sub>🚀 Generated with <a href="https://github.com/ivuorinen/gh-action-readme">gh-action-readme</a></sub>
|
||||
</div>
|
||||
94
templates_embed/templates/themes/gitlab/readme.tmpl
Normal file
94
templates_embed/templates/themes/gitlab/readme.tmpl
Normal file
@@ -0,0 +1,94 @@
|
||||
# {{.Name}}
|
||||
|
||||
{{if .Branding}}**{{.Branding.Icon}}** {{end}}**{{.Description}}**
|
||||
|
||||
---
|
||||
|
||||
## Installation
|
||||
|
||||
Add this action to your GitLab CI/CD pipeline or GitHub workflow:
|
||||
|
||||
### GitHub Actions
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- name: {{.Name}}
|
||||
uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}{{$val.Default}}{{else}}value{{end}}
|
||||
{{- end}}{{end}}
|
||||
```
|
||||
|
||||
### GitLab CI/CD
|
||||
|
||||
```yaml
|
||||
{{.Name | lower | replace " " "-"}}:
|
||||
stage: build
|
||||
image: node:20
|
||||
script:
|
||||
- # Your action logic here
|
||||
{{if .Inputs}}variables:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key | upper}}: {{if $val.Default}}{{$val.Default}}{{else}}value{{end}}
|
||||
{{- end}}{{end}}
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
{{if .Inputs}}
|
||||
### Input Parameters
|
||||
|
||||
{{range $key, $input := .Inputs}}
|
||||
#### `{{$key}}`
|
||||
- **Description**: {{$input.Description}}
|
||||
- **Type**: String{{if $input.Required}}
|
||||
- **Required**: Yes{{else}}
|
||||
- **Required**: No{{end}}{{if $input.Default}}
|
||||
- **Default**: `{{$input.Default}}`{{end}}
|
||||
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{if .Outputs}}
|
||||
### Output Parameters
|
||||
|
||||
{{range $key, $output := .Outputs}}
|
||||
#### `{{$key}}`
|
||||
- **Description**: {{$output.Description}}
|
||||
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Basic Example
|
||||
|
||||
```yaml
|
||||
{{.Name | lower | replace " " "-"}}:
|
||||
stage: deploy
|
||||
script:
|
||||
- echo "Using {{.Name}}"
|
||||
{{if .Inputs}}variables:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key | upper}}: "{{if $val.Default}}{{$val.Default}}{{else}}example{{end}}"
|
||||
{{- end}}{{end}}
|
||||
```
|
||||
|
||||
### Advanced Example
|
||||
|
||||
For more complex scenarios, refer to the [action.yml](./action.yml) specification.
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Action specification](./action.yml)
|
||||
- [Usage examples](./examples/)
|
||||
- [Contributing guidelines](./CONTRIBUTING.md)
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License.
|
||||
|
||||
---
|
||||
|
||||
*Generated with [gh-action-readme](https://github.com/ivuorinen/gh-action-readme)*
|
||||
33
templates_embed/templates/themes/minimal/readme.tmpl
Normal file
33
templates_embed/templates/themes/minimal/readme.tmpl
Normal file
@@ -0,0 +1,33 @@
|
||||
# {{.Name}}
|
||||
|
||||
{{.Description}}
|
||||
|
||||
## Usage
|
||||
|
||||
```yaml
|
||||
- uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}{{$val.Default}}{{else}}value{{end}}
|
||||
{{- end}}{{end}}
|
||||
```
|
||||
|
||||
{{if .Inputs}}
|
||||
## Inputs
|
||||
|
||||
{{range $key, $input := .Inputs}}
|
||||
- `{{$key}}` - {{$input.Description}}{{if $input.Required}} (required){{end}}{{if $input.Default}} (default: `{{$input.Default}}`){{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{if .Outputs}}
|
||||
## Outputs
|
||||
|
||||
{{range $key, $output := .Outputs}}
|
||||
- `{{$key}}` - {{$output.Description}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
245
templates_embed/templates/themes/professional/readme.tmpl
Normal file
245
templates_embed/templates/themes/professional/readme.tmpl
Normal file
@@ -0,0 +1,245 @@
|
||||
# {{.Name}}
|
||||
|
||||
{{if .Branding}}
|
||||
<div align="center">
|
||||
<img src="https://img.shields.io/badge/icon-{{.Branding.Icon}}-{{.Branding.Color}}" alt="{{.Branding.Icon}}" />
|
||||
<img src="https://img.shields.io/badge/status-stable-brightgreen" alt="Status" />
|
||||
<img src="https://img.shields.io/badge/license-MIT-blue" alt="License" />
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
## Overview
|
||||
|
||||
{{.Description}}
|
||||
|
||||
This GitHub Action provides a robust solution for your CI/CD pipeline with comprehensive configuration options and detailed output information.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Quick Start](#quick-start)
|
||||
- [Configuration](#configuration)
|
||||
{{if .Inputs}}- [Input Parameters](#input-parameters){{end}}
|
||||
{{if .Outputs}}- [Output Parameters](#output-parameters){{end}}
|
||||
- [Examples](#examples)
|
||||
{{if .Dependencies}}- [Dependencies](#-dependencies){{end}}
|
||||
- [Troubleshooting](#troubleshooting)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
|
||||
## Quick Start
|
||||
|
||||
Add the following step to your GitHub Actions workflow:
|
||||
|
||||
```yaml
|
||||
name: CI/CD Pipeline
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: {{.Name}}
|
||||
uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}"{{$val.Default}}"{{else}}"your-value-here"{{end}}
|
||||
{{- end}}{{end}}
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
This action supports various configuration options to customize its behavior according to your needs.
|
||||
|
||||
{{if .Inputs}}
|
||||
### Input Parameters
|
||||
|
||||
| Parameter | Description | Type | Required | Default Value |
|
||||
|-----------|-------------|------|----------|---------------|
|
||||
{{- range $key, $input := .Inputs}}
|
||||
| **`{{$key}}`** | {{$input.Description}} | `string` | {{if $input.Required}}✅ Yes{{else}}❌ No{{end}} | {{if $input.Default}}`{{$input.Default}}`{{else}}_None_{{end}} |
|
||||
{{- end}}
|
||||
|
||||
#### Parameter Details
|
||||
|
||||
{{range $key, $input := .Inputs}}
|
||||
##### `{{$key}}`
|
||||
|
||||
{{$input.Description}}
|
||||
|
||||
- **Type**: String
|
||||
- **Required**: {{if $input.Required}}Yes{{else}}No{{end}}{{if $input.Default}}
|
||||
- **Default**: `{{$input.Default}}`{{end}}
|
||||
|
||||
```yaml
|
||||
with:
|
||||
{{$key}}: {{if $input.Default}}"{{$input.Default}}"{{else}}"your-value-here"{{end}}
|
||||
```
|
||||
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{if .Outputs}}
|
||||
### Output Parameters
|
||||
|
||||
This action provides the following outputs that can be used in subsequent workflow steps:
|
||||
|
||||
| Parameter | Description | Usage |
|
||||
|-----------|-------------|-------|
|
||||
{{- range $key, $output := .Outputs}}
|
||||
| **`{{$key}}`** | {{$output.Description}} | `\${{"{{"}} steps.{{$.Name | lower | replace " " "-"}}.outputs.{{$key}} {{"}}"}}` |
|
||||
{{- end}}
|
||||
|
||||
#### Using Outputs
|
||||
|
||||
```yaml
|
||||
- name: {{.Name}}
|
||||
id: action-step
|
||||
uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
|
||||
- name: Use Output
|
||||
run: |
|
||||
{{- range $key, $output := .Outputs}}
|
||||
echo "{{$key}}: \${{"{{"}} steps.action-step.outputs.{{$key}} {{"}}"}}"
|
||||
{{- end}}
|
||||
```
|
||||
{{end}}
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```yaml
|
||||
- name: Basic {{.Name}}
|
||||
uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}"{{$val.Default}}"{{else}}"example-value"{{end}}
|
||||
{{- end}}{{end}}
|
||||
```
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
```yaml
|
||||
- name: Advanced {{.Name}}
|
||||
uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}"{{$val.Default}}"{{else}}"\${{"{{"}} vars.{{$key | upper}} {{"}}"}}"{{end}}
|
||||
{{- end}}{{end}}
|
||||
env:
|
||||
GITHUB_TOKEN: \${{"{{"}} secrets.GITHUB_TOKEN {{"}}"}}
|
||||
```
|
||||
|
||||
### Conditional Usage
|
||||
|
||||
```yaml
|
||||
- name: Conditional {{.Name}}
|
||||
if: github.event_name == 'push'
|
||||
uses: your-org/{{.Name | lower | replace " " "-"}}@v1
|
||||
{{if .Inputs}}with:
|
||||
{{- range $key, $val := .Inputs}}
|
||||
{{$key}}: {{if $val.Default}}"{{$val.Default}}"{{else}}"production-value"{{end}}
|
||||
{{- end}}{{end}}
|
||||
```
|
||||
|
||||
{{if .Dependencies}}
|
||||
## 📦 Dependencies
|
||||
|
||||
This action uses the following dependencies:
|
||||
|
||||
| Action | Version | Author | Description |
|
||||
|--------|---------|--------|-------------|
|
||||
{{- range .Dependencies}}
|
||||
| {{if .MarketplaceURL}}[{{.Name}}]({{.MarketplaceURL}}){{else}}{{.Name}}{{end}} | {{if .IsPinned}}🔒{{end}}{{.Version}} | [{{.Author}}](https://github.com/{{.Author}}) | {{.Description}} |
|
||||
{{- end}}
|
||||
|
||||
<details>
|
||||
<summary>📋 Dependency Details</summary>
|
||||
|
||||
{{range .Dependencies}}
|
||||
### {{.Name}}{{if .Version}} @ {{.Version}}{{end}}
|
||||
|
||||
{{if .IsPinned}}
|
||||
- 🔒 **Pinned Version**: Locked to specific version for security
|
||||
{{else}}
|
||||
- 📌 **Floating Version**: Using latest version (consider pinning for security)
|
||||
{{end}}
|
||||
- 👤 **Author**: [{{.Author}}](https://github.com/{{.Author}})
|
||||
{{if .MarketplaceURL}}- 🏪 **Marketplace**: [View on GitHub Marketplace]({{.MarketplaceURL}}){{end}}
|
||||
{{if .SourceURL}}- 📂 **Source**: [View Source]({{.SourceURL}}){{end}}
|
||||
{{if .WithParams}}
|
||||
- **Configuration**:
|
||||
```yaml
|
||||
with:
|
||||
{{- range $key, $value := .WithParams}}
|
||||
{{$key}}: {{$value}}
|
||||
{{- end}}
|
||||
```
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
||||
{{$hasLocalDeps := false}}
|
||||
{{range .Dependencies}}{{if .IsLocalAction}}{{$hasLocalDeps = true}}{{end}}{{end}}
|
||||
{{if $hasLocalDeps}}
|
||||
### Same Repository Dependencies
|
||||
{{range .Dependencies}}{{if .IsLocalAction}}
|
||||
- [{{.Name}}]({{.SourceURL}}) - {{.Description}}
|
||||
{{end}}{{end}}
|
||||
{{end}}
|
||||
|
||||
</details>
|
||||
{{end}}
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
1. **Authentication Errors**: Ensure you have set up the required secrets in your repository settings.
|
||||
2. **Permission Issues**: Check that your GitHub token has the necessary permissions.
|
||||
3. **Configuration Errors**: Validate your input parameters against the schema.
|
||||
|
||||
### Getting Help
|
||||
|
||||
- Check the [action.yml](./action.yml) for the complete specification
|
||||
- Review the [examples](./examples/) directory for more use cases
|
||||
- Open an issue if you encounter problems
|
||||
|
||||
## Contributing
|
||||
|
||||
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
||||
|
||||
### Development Setup
|
||||
|
||||
1. Fork this repository
|
||||
2. Create a feature branch
|
||||
3. Make your changes
|
||||
4. Add tests if applicable
|
||||
5. Submit a pull request
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
||||
|
||||
## Support
|
||||
|
||||
If you find this action helpful, please consider:
|
||||
|
||||
- ⭐ Starring this repository
|
||||
- 🐛 Reporting issues
|
||||
- 💡 Suggesting improvements
|
||||
- 🤝 Contributing code
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<sub>📚 Documentation generated with <a href="https://github.com/ivuorinen/gh-action-readme">gh-action-readme</a></sub>
|
||||
</div>
|
||||
Reference in New Issue
Block a user