Skip to content

Commit 6c4dcc8

Browse files
authored
Readme template support GHA (#176)
1 parent 8d8281f commit 6c4dcc8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md.gotmpl

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
{{- range . -}}{{ $sectionContent := index (ds "config") . -}}{{ if and $sectionContent (gt (len $sectionContent) 2048) -}}{{ . }} {{ end -}}{{ end -}}
1919
{{- end -}}
2020
{{- $firstNonEmptySection := (tmpl.Exec "nonEmptySections" $sections) | strings.TrimSpace | regexp.Replace " .*" "" -}}
21+
22+
{{/* Inspired https://github.com/Dirrk/action-docs/blob/master/src/default_template.tpl */}}
23+
{{- define "escape_chars" }}{{ . | strings.ReplaceAll "_" "\\_" | strings.ReplaceAll "|" "\\|" | strings.ReplaceAll "*" "\\*" }}{{- end }}
24+
{{- define "sanatize_string" }}{{ . | strings.ReplaceAll "\n\n" "<br><br>" | strings.ReplaceAll " \n" "<br>" | strings.ReplaceAll "\n" "<br>" | tmpl.Exec "escape_chars" }}{{- end }}
25+
2126
{{- define "tip_use_atmos" }}
2227
{{- if .is_terraform }}
2328
> [!TIP]
@@ -204,6 +209,29 @@ We literally have <a href="{{ $terraform_modules }}">*hundreds of other terrafor
204209
<!-- markdownlint-restore -->
205210
{{ end }}
206211

212+
{{- $action := (datasource "config") -}}
213+
{{ if has $action "inputs" }}
214+
## Inputs
215+
<!-- markdownlint-disable -->
216+
| Name | Description | Default | Required |
217+
|------|-------------|---------|----------|
218+
{{- range $key, $input := $action.inputs }}
219+
| {{ tmpl.Exec "escape_chars" $key }} | {{ if (has $input "description") }}{{ tmpl.Exec "sanatize_string" $input.description }}{{ else }}{{ tmpl.Exec "escape_chars" $key }}{{ end }} | {{ if (has $input "default") }}{{ tmpl.Exec "sanatize_string" $input.default }}{{ else }}N/A{{ end }} | {{ if (has $input "required") }}{{ $input.required }}{{ else }}false{{ end }} |
220+
{{- end }}
221+
<!-- markdownlint-restore -->
222+
{{- end }}
223+
224+
{{ if has $action "outputs" }}
225+
## Outputs
226+
<!-- markdownlint-disable -->
227+
| Name | Description |
228+
|------|-------------|
229+
{{- range $key, $output := $action.outputs }}
230+
| {{ tmpl.Exec "escape_chars" $key }} | {{ if (has $output "description") }}{{ tmpl.Exec "sanatize_string" $output.description }}{{ else }}{{ tmpl.Exec "escape_chars" $key }}{{ end }} |
231+
{{- end }}
232+
<!-- markdownlint-restore -->
233+
{{- end }}
234+
207235
{{ if has (ds "config") "include" }}
208236
{{ range $file := (datasource "config").include -}}
209237
{{ (include "includes" $file) }}

0 commit comments

Comments
 (0)