From 90e17f05b78de7ba891085ea2bdc7fa7cc0f42e6 Mon Sep 17 00:00:00 2001 From: Peter Evans <18365890+peter-evans@users.noreply.github.com> Date: Fri, 9 Apr 2021 14:45:59 +0900 Subject: [PATCH] Update readme --- .github/comment-template.md | 1 - README.md | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/comment-template.md b/.github/comment-template.md index e5f4e85..f566694 100644 --- a/.github/comment-template.md +++ b/.github/comment-template.md @@ -1,3 +1,2 @@ This is a test comment template - Render template variables such as {{ .foo }} and {{ .bar }}. diff --git a/README.md b/README.md index e9f57e5..8f893be 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,32 @@ The content must be [escaped to preserve newlines](https://github.community/t/se body: ${{ steps.get-comment-body.outputs.body }} ``` +### Using a markdown template + +In this example, a markdown template file is added to the repository at `.github/comment-template.md` with the following content. +``` +This is a test comment template +Render template variables such as {{ .foo }} and {{ .bar }}. +``` + +The template is rendered using the [render-template](https://github.com/chuhlomin/render-template) action and the result is used to create the comment. +```yml + - name: Render template + id: template + uses: chuhlomin/render-template@v1.2 + with: + template: .github/comment-template.md + vars: | + foo: this + bar: that + + - name: Create comment + uses: peter-evans/create-or-update-comment@v1 + with: + issue-number: 1 + body: ${{ steps.template.outputs.result }} +``` + ### Accessing issues and comments in other repositories You can create and update comments in another repository by using a [PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) instead of `GITHUB_TOKEN`.