Skip to content

Commit

Permalink
ensure not empty json matrix (#35)
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsoch@users.noreply.github.com>

Co-authored-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch and vsoch committed Sep 10, 2021
1 parent e90de88 commit 375b96b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
9 changes: 7 additions & 2 deletions parsers/docker/dockerbuild.go → parsers/docker/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,16 @@ func (s *DockerBuildParser) Parse(path string, changesOnly bool) error {

// Parse into json
outJson, _ := json.Marshal(results)
output := string(outJson)

// If we are running in a GitHub Action, set the outputs
// If it's empty, still provide an empty list
if output == "" {
output = "[]"
}

// If we are running in a GitHub Action, set the outputs
if utils.IsGitHubAction() {
fmt.Printf("::set-output name=dockerbuild_matrix::%s\n", string(outJson))
fmt.Printf("::set-output name=dockerbuild_matrix::%s\n", output)
}
}
return nil
Expand Down
6 changes: 5 additions & 1 deletion parsers/docker/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ func (s *DockerfileParser) Parse(path string, dryrun bool, changesOnly bool) err
// If we are running in a GitHub Action, set the outputs
if utils.IsGitHubAction() {
outJson, _ := json.Marshal(results)
fmt.Printf("::set-output name=dockerfile_matrix::%s\n", string(outJson))
output := string(outJson)
if output == "" {
output = "[]"
}
fmt.Printf("::set-output name=dockerfile_matrix::%s\n", output)
}
return nil
}
6 changes: 5 additions & 1 deletion parsers/docker/dockerfilelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ func (s *DockerfileListParser) Parse(path string, includeArgs bool, changesOnly
// If we are running in a GitHub Action, set the outputs
if utils.IsGitHubAction() {
outJson, _ := json.Marshal(results)
fmt.Printf("::set-output name=dockerfilelist_matrix::%s\n", string(outJson))
output := string(outJson)
if output == "" {
output = "[]"
}
fmt.Printf("::set-output name=dockerfilelist_matrix::%s\n", output)
}
return nil
}
6 changes: 5 additions & 1 deletion parsers/docker/hierarchy.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ func (s *DockerHierarchyParser) Update(dryrun bool) error {
// If we are running in a GitHub Action, set the outputs
if utils.IsGitHubAction() {
outJson, _ := json.Marshal(results)
fmt.Printf("::set-output name=dockerhierarchy_matrix::%s\n", string(outJson))
output := string(outJson)
if output == "" {
output = "[]"
}
fmt.Printf("::set-output name=dockerhierarchy_matrix::%s\n", output)
}

return nil
Expand Down

0 comments on commit 375b96b

Please sign in to comment.