Skip to content

allow empty outputs #2

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 7 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: ci

on:
- push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: make test
- name: automerge
uses: mhristof/github-action-automerge@v1.0.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


7 changes: 5 additions & 2 deletions action/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,24 @@ var md = `# {{ .Name }}

{{ .Description }}

{{ if .Inputs -}}
## Inputs

| Name | Description | Default | Required |
| ---- | ----------- | ------- | -------- |
{{ range $key, $value := .Inputs -}}
| {{ $key }} | {{$value.Description}} | {{$value.Default }} | {{ $value.Required }}|
{{ end }}

{{ end -}}
{{ if .Outputs -}}
## Outputs

| Name | Description |
| ---- | ----------- |
{{ range $key, $value := .Outputs -}}
| {{ $key }} | {{$value.Description}} |
{{ end }}`
{{ end }}
{{ end -}}`

func (c *Config) Markdown() string {
tmpl, err := template.New("markdown").Parse(md)
Expand Down
47 changes: 47 additions & 0 deletions action/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,59 @@ func TestMarkdown(t *testing.T) {
| ---- | ----------- | ------- | -------- |
| who-to-greet | Who to greet | World | true|

## Outputs

| Name | Description |
| ---- | ----------- |
| random-number | Random number |

`),
},
{
name: "no outputs",
yaml: heredoc.Doc(`
name: 'Hello World'
description: 'Greet someone'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
`),
expected: heredoc.Doc(`
# Hello World

Greet someone

## Inputs

| Name | Description | Default | Required |
| ---- | ----------- | ------- | -------- |
| who-to-greet | Who to greet | World | true|

`),
},
{
name: "no inputs",
yaml: heredoc.Doc(`
name: 'Hello World'
description: 'Greet someone'
outputs:
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-id }}
`),
expected: heredoc.Doc(`
# Hello World

Greet someone

## Outputs

| Name | Description |
| ---- | ----------- |
| random-number | Random number |

`),
},
}
Expand Down
11 changes: 5 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module github.com/mhristof/githubactions-docs

go 1.14
go 1.16

require (
github.com/MakeNowJust/heredoc v1.0.0
github.com/atsushinee/go-markdown-generator v0.0.0-20191121114853-83f9e1f68504
github.com/mhristof/go-update v0.1.0
github.com/riywo/#shell v0.0.0-20200815045211-7d26008be1ab
github.com/sirupsen/logrus v1.5.0
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.5.1
gopkg.in/yaml.v2 v2.2.8
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0
gopkg.in/yaml.v2 v2.4.0
)
Loading