peter-evans / find-comment Goto Github PK
View Code? Open in Web Editor NEWA GitHub action to find an issue or pull request comment
License: MIT License
A GitHub action to find an issue or pull request comment
License: MIT License
Hi,
Would it be possible to add a parameter to get the nth comment that matches the search criteria? The use case I have in mind involves a tracker issue with multiple comments by the github-actions bot, where each comment corresponds to a different sub-topic and is automatically updated using the create-or-update-comment
action. It would be nice to be able to, for example, get the third comment by the bot using a parameter instead of having to rely on string matches.
Thank you for the wonderful action, it helps me a lot!
Currently I use it to fetch the body of a comment to be used in my workflow, but I find that I can't get the comment by comment id.
Would you please add the feature so that I can get a comment by comment id?
When using this action with this configuration:
name: Comment translation list
on: push
jobs:
translations:
runs-on: ubuntu-latest
container:
image: leviy/build-image
steps:
- name: Find comment with added translation keys
uses: peter-evans/find-comment@v1
id: findComment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: New added translation keys
We are using this docker image: https://hub.docker.com/r/leviy/build-image
It fails with this error:
Run peter-evans/find-comment@v1
/usr/bin/docker exec b2e6705e275dc30ba9e27b1ee7700ff5c555983034fb2f2dd3fbfdad957083ac sh -c "cat /etc/*release | grep ^ID"
Error: Not Found
We don't have this with other actions, for example this one: necojackarc/auto-request-review
Hi team,
Currently, we have the following vulnerability, can we look into fixing it?
[
{
"createdAt": "2023-02-02T17:50:38Z",
"dismissedAt": null,
"securityVulnerability": {
"package": {
"name": "json5"
},
"severity": "HIGH"
}
}
]
It is possible that #97 fixed it, but we need a new release
Hi @peter-evans, I really like this action because how seamlessly it finds comments on other repositories.
Can this be enhanced to get the PR description/body?
If so, I would use your other action (Create or Update Comment) to update the PR description (would require you to update that one as well).
Please :)
This is an issue used by this action's workflow test cases.
The action will output the comment ID of the first comment matching the search criteria.
I'm wondering if it's possible to find the last comment?
Hi, I'm satisfied with this product.
However, when I was testing my github-action
with your product, I found something strange.
After the several tests, I think maybe you didn't deal the case that comment-body
contatins \n
character for some reason
These are what I tested...
I used this code at
Find Comment
andRun echo
step below- name: Find Comment uses: peter-evans/[email protected] id: fc with: issue-number: 1 body-includes: ${{ github.event.comment.body }} - run: | echo ${{ steps.fc.outputs.comment-id }} echo ${{ steps.fc.outputs.comment-body }} echo ${{ steps.fc.outputs.comment-author }}
When I posted an issue comment like (not includes \n
)
[질문] 개행아아아아
-> get comment-author
well
When I posted an issue comment like (inclues \n
)
[질문]
개행아아아아
-> it occurs error 개행아아아아 commands not found
. BUT, actually 개행아아아아
is not a command but a part of comment-body
When I posted an issue comment like (not inclues \n
, space
)
[질문]
-> it occurs error \r command not found
.
When running the latest version of this action, github shows a warning:
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: peter-evans/find-comment@v2
The action should be updated to use a nodejs20 runner.
Hello @peter-evans , thanks for this very nice tool!
Is there a way of fetching the body of the matching comment? I.e., getting the body of a comment that matched the search keyword?
Thanks in advance!
Pedro
At https://github.com/step-security/secure-workflows we are building a knowledge-base (KB) of GITHUB_TOKEN permissions needed by different GitHub Actions. When developers try to set minimum token permissions for their workflows, they can use this knowledge-base instead of trying to research permissions needed by each GitHub Action they use.
Below you can see the KB of your GITHUB Action.
name: 'Find Comment'
github-token:
action-input:
input: token
is-default: true
permissions:
issues: read
issues-reason: to get issue comment #Checkout: https://github.com/peter-evans/find-comment#accessing-issues-and-pull-requests-in-other-repositories
pull-requests: read
pull-requests-reason: to get PR comment
If you think this information is not accurate, or if in the future your GitHub Action starts using a different set of permissions, please create an issue at https://github.com/step-security/secure-workflows/issues to let us know.
This issue is automatically created by our analysis bot, feel free to close after reading :)
GitHub asks users to define workflow permissions, see https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/ and https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token for securing GitHub workflows against supply-chain attacks.
Setting minimum token permissions is also checked for by Open Source Security Foundation (OpenSSF) Scorecards. Scorecards recommend using https://github.com/step-security/secure-workflows so developers can fix this issue in an easier manner.
Hi
Thank you very much for this action - I just started to use it within a workflow. One thing I noticed is that "comment-author" for the author "github-actions" is not working.
My workflow starts like this:
on:
issues:
types: [closed]
jobs:
close-activity:
runs-on: ubuntu-latest
steps:
- name: Find Comment
uses: peter-evans/[email protected]
id: fc
with:
issue-number: ${{ github.event.issue.number }}
comment-author: github-actions
body-includes: Kimai activity created, ID-
It works fine when i only use "body-includes" - but when I want to further restrict it to the author "github-actions" it's not working anymore. Any hints or thoughts from your end?
It's possible to a similar logic to find the Issue number by string?
- name: 🔎 Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: OctoDNS Plan
Run peter-evans/find-comment@v2
with:
body-includes: OctoDNS Plan
token: ***
repository: xxx/yyy
direction: first
nth: 0
Error: Not Found
I've tried setting a token using GITHUB_TOKEN
and a PAT
, and not - nothing seems to work.
Thank you for creating this package!
For completeness, I think one of the outputs should be the comment-author
. In my use case, I am trying to ensure that the most recent comment with some text is not a specific author (a bot, in my case). It's not clear whether this is possible to determine without outputting the comment author.
Example of my use case:
- name: Find /deploy in PR (if applicable)
uses: peter-evans/find-comment@v1
if: ${{ github.event.client_payload.slash_command.args.named.pr_number }}
id: fc
with:
issue-number: ${{ github.event.client_payload.slash_command.args.named.pr_number }}
body-includes: /deploy
direction: last
- name: Check whether we need to deploy (/deploy, if applicable)
if: ${{ github.event.client_payload.slash_command.args.named.pr_number }} && ${{ steps.fc.outputs.comment-id }} != 0 && ${{ steps.fc.outputs.comment-author }} != 'github-action[bot]'
run: ...
Hi - first of all thanks for this action/code.
I'm using it to...well, find a comment :) and I was trying to make the search case-insensitive.
In the regex, I've tried:
\^.*no-experiment.*$\gi << silently fails (no error, but doesn't find "no-experiment" or "no-experimenT")
(?i)^.*no-experiment.*$ << throws an error
The error from the second regex is:
Error: Invalid regular expression: /(?i)^.*no-experiment.*$/: Invalid group
So it seems that the regex start/end /.../
are being added when the regex is parsed, so I'm unable to add anything outside the regex start/end (no flags i.e. case insensitive).
Do you know of a way I can achieve above? Or I can also submit a PR to make the search for body-includes
case insensitive if it wasn't intended to be case sensitive (is it?)
Hi @peter-evans ,
I am trying to find a comment located on a merged and closed pull request. Can I achieve this with find-comment
? I tried something like shown below but it does not do the job.
on:
pull_request:
types: [closed]
env:
TWEET_KEYWORD: '__[tweet]__'
jobs:
publish_tweet:
runs-on: ubuntu-latest
if: github.event.pull_request.merged
steps:
- name: find the tweet comment matching the keyword env.TWEET_KEYWORD
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: github-actions[bot]
body-includes: ${{ env.TWEET_KEYWORD }}
I have following steps in my workflow. Repeated runs of the workflow does NOT update the existing comment but always creates new comments.
Assumption based on docs body-includes
matches if a part of the string matches.
- name: Find Validation Comment
uses: peter-evans/[email protected]
id: fc
with:
issue-number: ${{ github.event.issue.number }}
comment-author: github-actions
body-includes: We have successfully validated your inputs
- name: Validation comment
uses: peter-evans/[email protected]
with:
issue-number: ${{ github.event.issue.number }}
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
We have successfully validated your inputs and proceed with account creation…
I am trying to use this action in my private repo. I generated a PAT, added it to my GitHub repo -> action -> secret with the name TEST, and included the token in my .yaml file as follows:
name: TestPE
on: [workflow_dispatch, pull_request]
concurrency:
group: pr-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
test_private_action_job:
name: TestingPE
runs-on: ubuntu-latest
steps:
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Build output
token: ${{ secrets.TEST }}
However, when I run the workflow, I receive Run peter-evans/find-comment@v2 Error: Not Found
on the Find Comment
step. Please let me know what I am doing wrong.
Hi, I wonder if this action could find multiple matches? From the readme, it seems that it only supports first
and last
matches?
Currently to find a comment, we need to specify an issue number https://github.com/peter-evans/find-comment/blob/main/action.yml#L10-L12
It would be a great addition to have the option to specify a commit instead. An example use case would be :
Hi,
I am testing this workflow and it works like a charm, except for this issue that I'm facing:
If the comment that matches the keyword that I seek is the 31st comment or more in the thread, find-comment
does not detect it. Have you experienced this issue?
Thank you,
Pedro
Is there a way to check if the LAST (a.k.a. more recent) comment was made by a specific author?
It would be great to be able to match comment bodies based on regex whereas right now this only works with containment. From briefly looking at the source code I think this might work by replacing references to string.includes
with string.match
. Happy to try and contribute this feature if there is interest.
I try to find comments by github-action bot but can't Receive empty outputs
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.