Skip to content

Commit

Permalink
feat: add links to external actions
Browse files Browse the repository at this point in the history
  • Loading branch information
matty-rose committed Oct 24, 2021
1 parent 4274de7 commit 185df04
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/document/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,7 @@ func (m *MarkdownDocument) WriteTable(columns []string, rows [][]string) (*Markd

return m, nil
}

func CreateMarkdownLink(title, url string) string {
return fmt.Sprintf("[%s](%s)", title, url)
}
11 changes: 10 additions & 1 deletion pkg/generator/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,16 @@ func (mdg markdownGenerator) Generate(action *types.CompositeAction) string {
if len(action.Uses) != 0 {
var externalActions [][]string
for _, act := range action.Uses {
externalActions = append(externalActions, []string{act.Name, act.Creator, act.Version, act.StepName, act.StepID})
externalActions = append(
externalActions,
[]string{
document.CreateMarkdownLink(act.Name, act.GetLink()),
act.Creator,
act.Version,
act.StepName,
act.StepID,
},
)
}

doc.WriteNewLine()
Expand Down
6 changes: 6 additions & 0 deletions pkg/types/external_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ THE SOFTWARE.
*/
package types

import "fmt"

// ExternalAction represents a single external action that is used by the composite action.
type ExternalAction struct {
Creator string
Expand All @@ -29,3 +31,7 @@ type ExternalAction struct {
StepName string
StepID string
}

func (e ExternalAction) GetLink() string {
return fmt.Sprintf("https://github.com/%s/%s/tree/%s", e.Creator, e.Name, e.Version)
}

0 comments on commit 185df04

Please sign in to comment.