This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch gha-summary
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 936d50a8ce5e815c6f57245aed8c77a0c389ec9b
Author: kezhenxu94 <[email protected]>
AuthorDate: Tue May 10 15:16:22 2022 +0800

    Test
---
 .github/workflows/license-eye-check.yaml |  1 +
 commands/header_check.go                 | 25 +++++++++++++++++--------
 test.1.go                                |  1 +
 test.go                                  |  1 +
 4 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/license-eye-check.yaml 
b/.github/workflows/license-eye-check.yaml
index d650d5b..fbb26c9 100644
--- a/.github/workflows/license-eye-check.yaml
+++ b/.github/workflows/license-eye-check.yaml
@@ -22,6 +22,7 @@ on:
   push:
     branches:
       - main
+      - gha-summary
 
 jobs:
   build-license-eye:
diff --git a/commands/header_check.go b/commands/header_check.go
index 802fde7..2d6ef88 100644
--- a/commands/header_check.go
+++ b/commands/header_check.go
@@ -18,7 +18,6 @@
 package commands
 
 import (
-       "fmt"
        "os"
 
        "github.com/apache/skywalking-eyes/internal/logger"
@@ -46,13 +45,7 @@ var CheckCommand = &cobra.Command{
 
                logger.Log.Infoln(result.String())
 
-               if summaryFileName := os.Getenv("GITHUB_STEP_SUMMARY"); 
summaryFileName != "" {
-                       if summaryFile, err := os.OpenFile(summaryFileName, 
os.O_WRONLY|os.O_APPEND, 0o644); err == nil {
-                               defer summaryFile.Close()
-                               _, _ = summaryFile.WriteString(result.String())
-                               _, _ = 
summaryFile.WriteString(fmt.Sprintln(result.Error()))
-                       }
-               }
+               writeSummaryQuietly(&result)
 
                if result.HasFailure() {
                        if err := review.Header(&result, &Config); err != nil {
@@ -64,3 +57,19 @@ var CheckCommand = &cobra.Command{
                return nil
        },
 }
+
+func writeSummaryQuietly(result *header.Result) {
+       if summaryFileName := os.Getenv("GITHUB_STEP_SUMMARY"); summaryFileName 
!= "" {
+               if summaryFile, err := os.OpenFile(summaryFileName, 
os.O_WRONLY|os.O_APPEND, 0o644); err == nil {
+                       defer summaryFile.Close()
+                       _, _ = summaryFile.WriteString(result.String())
+                       if result.HasFailure() {
+                               _, _ = summaryFile.WriteString("The following 
files are lack of license headers\n")
+                               for _, failure := range result.Failure {
+                                       _, _ = summaryFile.WriteString(failure)
+                                       _, _ = summaryFile.WriteString("\n")
+                               }
+                       }
+               }
+       }
+}
diff --git a/test.1.go b/test.1.go
new file mode 100644
index 0000000..06ab7d0
--- /dev/null
+++ b/test.1.go
@@ -0,0 +1 @@
+package main
diff --git a/test.go b/test.go
new file mode 100644
index 0000000..06ab7d0
--- /dev/null
+++ b/test.go
@@ -0,0 +1 @@
+package main

Reply via email to