From edd647f1db8bd46be2b19900f9b5f38237027c30 Mon Sep 17 00:00:00 2001 From: knanao Date: Wed, 4 Jan 2023 14:48:24 +0900 Subject: [PATCH 1/2] Update planpreview comment format --- tool/actions-plan-preview/planpreview.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tool/actions-plan-preview/planpreview.go b/tool/actions-plan-preview/planpreview.go index 3f7d9f4650..f09782e2ec 100644 --- a/tool/actions-plan-preview/planpreview.go +++ b/tool/actions-plan-preview/planpreview.go @@ -176,13 +176,13 @@ func makeCommentBody(event *githubEvent, r *PlanPreviewResult) string { } b.WriteString(fmt.Sprintf(hasChangeTitleFormat, event.HeadCommit, len(r.Applications))) + b.WriteString("\n## Plans\n\n") changedApps, pipelineApps, quickSyncApps := groupApplicationResults(r.Applications) var detailLen int - for _, app := range changedApps { - fmt.Fprintf(&b, "\n## %s\n", makeTitleText(&app.ApplicationInfo)) + fmt.Fprintf(&b, "\n### %s\n", makeTitleText(&app.ApplicationInfo)) fmt.Fprintf(&b, "Sync strategy: %s\n", app.SyncStrategy) fmt.Fprintf(&b, "Summary: %s\n\n", app.PlanSummary) @@ -211,7 +211,7 @@ func makeCommentBody(event *githubEvent, r *PlanPreviewResult) string { } if len(pipelineApps)+len(quickSyncApps) > 0 { - b.WriteString("\n## No resource changes were detected but the following apps will also be triggered\n") + b.WriteString("\n### No resource changes were detected but the following apps will also be triggered\n") if len(pipelineApps) > 0 { b.WriteString("\n###### `PIPELINE`\n") @@ -232,13 +232,13 @@ func makeCommentBody(event *githubEvent, r *PlanPreviewResult) string { return b.String() } - fmt.Fprintf(&b, "\n---\n\n## NOTE\n\n") + fmt.Fprintf(&b, "\n## NOTE\n\n") if len(r.FailureApplications) > 0 { fmt.Fprintf(&b, "**An error occurred while building plan-preview for the following applications**\n") for _, app := range r.FailureApplications { - fmt.Fprintf(&b, "\n## %s\n", makeTitleText(&app.ApplicationInfo)) + fmt.Fprintf(&b, "\n### %s\n", makeTitleText(&app.ApplicationInfo)) fmt.Fprintf(&b, "Reason: %s\n\n", app.Reason) var lang = "diff" @@ -256,7 +256,7 @@ func makeCommentBody(event *githubEvent, r *PlanPreviewResult) string { fmt.Fprintf(&b, "**An error occurred while building plan-preview for applications of the following Pipeds**\n") for _, piped := range r.FailurePipeds { - fmt.Fprintf(&b, "\n## piped: [%s](%s)\n", piped.PipedID, piped.PipedURL) + fmt.Fprintf(&b, "\n### piped: [%s](%s)\n", piped.PipedID, piped.PipedURL) fmt.Fprintf(&b, "Reason: %s\n\n", piped.Reason) } } From 6ca05c7923e9d30c55f09ffaf5f44a27f7e37031 Mon Sep 17 00:00:00 2001 From: knanao Date: Wed, 4 Jan 2023 14:55:25 +0900 Subject: [PATCH 2/2] fixup --- tool/actions-plan-preview/planpreview.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tool/actions-plan-preview/planpreview.go b/tool/actions-plan-preview/planpreview.go index f09782e2ec..632658a9cd 100644 --- a/tool/actions-plan-preview/planpreview.go +++ b/tool/actions-plan-preview/planpreview.go @@ -176,9 +176,11 @@ func makeCommentBody(event *githubEvent, r *PlanPreviewResult) string { } b.WriteString(fmt.Sprintf(hasChangeTitleFormat, event.HeadCommit, len(r.Applications))) - b.WriteString("\n## Plans\n\n") changedApps, pipelineApps, quickSyncApps := groupApplicationResults(r.Applications) + if len(changedApps)+len(pipelineApps)+len(quickSyncApps) > 0 { + b.WriteString("\n## Plans\n\n") + } var detailLen int for _, app := range changedApps {