Skip to content

Commit

Permalink
Merge pull request #10 from jerry153fish/feat/#2-fix-lint
Browse files Browse the repository at this point in the history
#2 fix lint
  • Loading branch information
jerry153fish authored Oct 19, 2024
2 parents f3c80d6 + f25184c commit 3c16cba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
Expand All @@ -36,6 +38,8 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup action.yaml for local test
run: |
Expand Down
18 changes: 7 additions & 11 deletions internal/commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,26 +200,26 @@ func isValidRegex(pattern string) (bool, error) {
}

// SetGitHubOutput sets a GitHub Actions output variable.
func SetGitHubOutput(name, value string) error {
func SetGitHubOutput(name, value string) {
// Get the GITHUB_OUTPUT environment variable
outputFile := os.Getenv("GITHUB_OUTPUT")
if outputFile == "" {
return fmt.Errorf("GITHUB_OUTPUT is not set")
log.Println("GITHUB_OUTPUT is not set")
return
}

// Write the output to the environment file
f, err := os.OpenFile(outputFile, os.O_APPEND|os.O_WRONLY, 0600)
if err != nil {
return fmt.Errorf("failed to open output file: %v", err)
log.Printf("failed to open output file: %v", err)
return
}
defer f.Close()

// Format the output and write it to the file
if _, err := f.WriteString(fmt.Sprintf("%s=%s\n", name, value)); err != nil {
return fmt.Errorf("failed to write output: %v", err)
log.Printf("failed to write output: %v", err)
}

return nil
}

func Delta() {
Expand All @@ -238,17 +238,13 @@ func Delta() {
log.Fatalf("Error getting diff between commits: %v", err)
}

log.Println(diffs)

deltas := FilterStrings(diffs, cfg.FilePatterns, cfg.IgnoreFilePatterns)

log.Println(deltas)

if len(deltas) > 0 {
SetGitHubOutput("is_detected", "true")
jsonData, err := json.Marshal(deltas)
if err != nil {
log.Println("Error marshalling to JSON: %v", err)
log.Printf("Error marshalling to JSON: %v", err)
}
SetGitHubOutput("delta_files", string(jsonData))
} else {
Expand Down

0 comments on commit 3c16cba

Please sign in to comment.