GithubHelp home page GithubHelp logo

edumserrano / find-create-or-update-comment Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 2.0 64 KB

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

License: MIT License

comment github github-action github-actions pull-request issue create-comment find-comment update-comment

find-create-or-update-comment's Introduction

Find, create or update comment GitHub action

Test GitHub action Test GitHub action from GH Marketplace Markdown link check 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@v2
  with:
    issue-number: ${{ github.event.pull_request.number }}
    body-includes: '<!-- some-unique-id -->'
    comment-author: 'github-actions[bot]'
    body: | # can be a single value or you can compose text with multi-line values
      <!-- some-unique-id -->
      My awesome comment
    edit-mode: replace

The above usage example is using a trick to uniquely identify a comment with some text.

The GitHub comment contains a markdown comment using the <!-- this is a comment --> syntax. The markdown comment text should then be a unique identifier that we can use to search for. This way we can set unique ids for the comments but don't make them visible to the user/whoever is reading the comment on GitHub.

Also note that you can pass input from other steps into the body param by doing something like:

body: |
  <!-- some-unique-id -->
  ${{ steps.some-step-id.outputs.some-step-output }}

Alternatively to using an inline body you can use the body-path to specify a file to use.

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. Cannot be used in conjunction with body-regex. yes, unless body-regex is used. -
body-regex A regular expression to search for in the body of comments. Cannot be used in conjunction with body-includes. yes, unless body-includes is used. -
direction Search direction, specified as first or last no first
nth 0-indexed number, specifying which comment to update if multiple are found . no 0
comment-author The GitHub user name of the comment author. false -
body The comment body. Cannot be used in conjunction with body-path. yes, unless body-path is used. -
body-path The path to a file containing the comment body. Cannot be used in conjunction with body. yes, unless body is used. -
edit-mode The mode when updating a comment, replace or append. false append
append-separator The separator to use when appending to an existing comment. (newline, space, none). false newline
reactions A comma separated list of reactions to add to the comment (+1, -1, laugh, confused, heart, hooray, rocket, eyes). false -
reactions-edit-mode The mode when updating comment reactions, replace or append. false append

Dev notes

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

find-create-or-update-comment's People

Contributors

dependabot[bot] avatar edumserrano avatar stovmascript avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

find-create-or-update-comment's Issues

New Release

Corrected

Currently v1 is a couple of commits behind main which upstream has a fair amount of minor updates.

If the v1 tag could be updated to latest commit, that would be appreciated.

Workflow test issue

This issue is used to test that the action provided by this repo works as expected.
The test workflow will be updating a comment on this issue.

Release `main` to v2 (or create v3)

It looks like you updated in the transitive dependencies to versions that use Node 20. However, it has been merged to the v2 branch yet.

Could you merge to v2 or create a v3 release if you're worried about breaking compatibility?

Thanks for this great action!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.