Skip to content

Commit

Permalink
Merge pull request #5 from racklet/relative_paths
Browse files Browse the repository at this point in the history
Output relative paths, not absolute
  • Loading branch information
luxas authored Jun 10, 2021
2 parents 6fc3785 + a7c67bd commit 617d830
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
5 changes: 1 addition & 4 deletions cmd/render-drawio/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"os"
"strings"
"time"

"github.com/racklet/render-drawio-action/pkg/render"
Expand Down Expand Up @@ -85,7 +84,5 @@ func run() error {
}

// Set the GH Action output
render.GitHubActionSetOutput("rendered-files", strings.Join(outputFiles, " "))

return nil
return render.GitHubActionSetFilesOutput("rendered-files", cfg.RootDir, outputFiles)
}
17 changes: 17 additions & 0 deletions pkg/render/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,20 @@ func GitHubActionSetOutput(key, val string) {
zap.S().Infow("Setting Github Action output", key, val)
fmt.Printf("::set-output name=%s::%s\n", key, val)
}

func GitHubActionSetFilesOutput(key, rootDir string, files []string) error {
// Only run filepath.Rel if rootDir != ""
if len(rootDir) != 0 {
var err error
for i := range files {
// Make the file path relative to root dir
files[i], err = filepath.Rel(rootDir, files[i])
if err != nil {
return err
}
}
}
// Run the generic function
GitHubActionSetOutput(key, strings.Join(files, " "))
return nil
}

0 comments on commit 617d830

Please sign in to comment.