From 1704dc9b93cf1dd56395633f3c159087e4a3d860 Mon Sep 17 00:00:00 2001 From: Torsten Ueberschar Date: Thu, 6 Oct 2022 18:00:03 +0200 Subject: [PATCH 1/2] add file comment without title --- Program.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index c2f2bac..df143e7 100644 --- a/Program.cs +++ b/Program.cs @@ -43,13 +43,21 @@ static async System.Threading.Tasks.Task Main(string[] args) } string comment = string.Empty; - if (!string.IsNullOrEmpty(COMMENT_FROM_FILE) && !string.IsNullOrWhiteSpace(COMMENT_FROM_FILE)) + if (!string.IsNullOrEmpty(COMMENT_FROM_FILE) && !string.IsNullOrWhiteSpace(COMMENT_FROM_FILE) && !string.IsNullOrWhiteSpace(COMMENT_TITLE)) { string title = COMMENT_TITLE.ToString().Trim(); title = !string.IsNullOrEmpty(title) ? title : "Gitea Comment"; Console.WriteLine("Reading from file"); comment = $"## {title}\\n```text\\n"+System.IO.File.ReadAllText(COMMENT_FROM_FILE.ToString()).Trim().Replace(Environment.NewLine, "\\n")+"\\n```"; } + else if (!string.IsNullOrEmpty(COMMENT_FROM_FILE) + && !string.IsNullOrWhiteSpace(COMMENT_FROM_FILE) + && string.IsNullOrWhiteSpace(COMMENT_TITLE)) + { + Console.WriteLine("Reading from file"); + var file = await System.IO.File.ReadAllTextAsync(COMMENT_FROM_FILE); + comment = file.Trim().Replace(Environment.NewLine, @"\n"); + } else { Console.WriteLine("Reading from specified text"); From c3849fab637382f3e748f5bad83c996ab72367b4 Mon Sep 17 00:00:00 2001 From: Torsten Ueberschar Date: Thu, 6 Oct 2022 18:00:13 +0200 Subject: [PATCH 2/2] update README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index a786a74..718c83b 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,22 @@ steps: status: [ failure ] event: pull_request ``` + +Example reference providing Markdown comments from Marktdown files: + +Do not specify the title so that the contents of the file are not +encapsulated within a code block. + +```yml +steps: +- name: post-to-gitea-pr + image: tsakidev/giteacomment:latest + settings: + gitea_token: + from_secret: gitea_token + gitea_base_url: http://gitea.example.com + comment_from_file: "/path/to/file.md" + when: + status: [ failure ] + event: pull_request +``` \ No newline at end of file