Skip to content

Commit

Permalink
added github output file support
Browse files Browse the repository at this point in the history
  • Loading branch information
shivasurya committed Oct 15, 2024
1 parent dbe72a7 commit b29bd09
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: 'Code-Pathfinder OSS'
description: 'Code-Pathfinder open-source alternative to CodeQL'
inputs:
command:
description: 'Command to run'
description: 'Command to run example: ci, query'
required: true
default: 'ci'
project:
description: 'Source code to scan'
description: 'Source code to scan. eg: /path/to/project'
required: true
default: ${{ github.workspace }}
ruleset:
Expand Down
5 changes: 5 additions & 0 deletions sourcecode-parser/cmd/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"encoding/json"
"fmt"
"github.com/shivasurya/code-pathfinder/sourcecode-parser/graph"

Check failure on line 6 in sourcecode-parser/cmd/ci.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
"io"
"net/http"
"os"
Expand Down Expand Up @@ -70,6 +71,10 @@ var ciCmd = &cobra.Command{
// TODO: Add sarif file support
if output == "json" {
if outputFile != "" {
if graph.IsGitHubActions() {
// append GITHUB_WORKSPACE to output file path
outputFile = os.Getenv("GITHUB_WORKSPACE") + "/" + outputFile
}
file, err := os.Create(outputFile)
if err != nil {
fmt.Println("Error creating output file: ", err)
Expand Down
5 changes: 5 additions & 0 deletions sourcecode-parser/graph/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"log"
"os"
)

var verboseFlag bool
Expand Down Expand Up @@ -63,3 +64,7 @@ func Fmt(format string, args ...interface{}) {
fmt.Printf(format, args...)
}
}

func IsGitHubActions() bool {
return os.Getenv("GITHUB_ACTIONS") == "true"
}

0 comments on commit b29bd09

Please sign in to comment.