Skip to content

A composite GitHub action that can be used to create or update a GitHub issue/pull request comment.

License

Notifications You must be signed in to change notification settings

edumserrano/find-create-or-update-comment

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Find, create or update comment GitHub action

Test GitHub action Test GitHub action from GH Marketplace GitHub Marketplace

License: MIT GitHub Sponsors LinkedIn

Description

A composite GitHub action that can be used to find a GitHub Issue or Pull Request comment by a specified value and then update the comment if found or create it if not found.

Why should you use this action ?

This is nothing more than a combination of the awesome work done by Peter Evans. I'm combining the find-comment and the create-or-update-comment because I found that I end up using those actions together a lot of the time.

This is a implementation of what is described in the docs for create-or-update-comment.

Usage

- name: Update PR with test results
  uses: edumserrano/find-create-or-update-comment@v1
  with:
    issue-number: ${{ github.event.pull_request.number }}
    body-includes: '<!-- pr-test-results -->'
    comment-author: 'github-actions[bot]'
    body: | # can be a single value or you can compose text with multi-line values
      <!-- pr-test-results -->
      ${{ steps.test-results.outputs.results }}
    edit-mode: replace

Action inputs

Name Description Required Default value
token GITHUB_TOKEN or a repo scoped PAT. yes github.token (job token)
repository The full name of the repository containing the issue or pull request where to find, create or update the comment. yes github.repository (current repository)
issue-number The number of the issue or pull request in which to find, create or update the comment. yes -
body-includes A string to search for in the body of comments. yes -
comment-author The GitHub user name of the comment author. false -
body The comment body. yes -
edit-mode The mode when updating a comment, replace or append. yes -
reactions A comma separated list of reactions to add to the comment (+1, -1, laugh, confused, heart, hooray, rocket, eyes). false -

Tips

  • In your issue or pull request comment, you can include a piece of text that is a comment and therefore is not rendered by using the HTML tag comment syntax: <!-- this is a comment -->. Then you can use that HTML comment tag as an identifier for the comment you want to find and update.
    • The idea is that the HTML tag comment you choose will serve as unique identifier for the comment you want to find and update. This is a much better way to be sure that you will not get a false positive by searching for a non-comment piece of text.

Dev notes

For notes aimed at developers working on this repo or just trying to understand it go here.

About

A composite GitHub action that can be used to create or update a GitHub issue/pull request comment.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •