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 783e0dc392c78c8107e3787a6e8d2cc7b0aca2d5 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 | 23 ++++++++++++++++------- test.1.go | 1 + test.go | 1 + 4 files changed, 19 insertions(+), 7 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..3dea0e3 100644 --- a/commands/header_check.go +++ b/commands/header_check.go @@ -46,13 +46,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 +58,18 @@ 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("\nThe following files are lack of license headers\n") + for _, failure := range result.Failure { + _, _ = summaryFile.WriteString(fmt.Sprintf("- %s\n", failure)) + } + } + } + } +} 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
