unsplash / comment-on-pr Goto Github PK
View Code? Open in Web Editor NEWA GitHub Action to comment on the relevant open PR when a commit is pushed.
License: MIT License
A GitHub Action to comment on the relevant open PR when a commit is pushed.
License: MIT License
Hello,
First of all, thank you for this action, it's useful!
I'm running it in my CI but I got an issue here: https://github.com/UnlyEd/next-right-now/runs/474616496 (section "Comment PR (Deployment success)")
And got this error:
Couldn't find an open pull request for branch with head at 68cd1584010cc948222fb38ea56067020d8eacda.
It looks close to #8 but I don't think that's the same problem.
In my case, when I push many commits in a short time, the HEAD is no longer on my initial commit and comment-on-pr
can't associate my commit with the HEAD.
Any ideas to solve it?
Maybe by adding an environment variable to set ref to use? Something provided Github Actions, like:
- name: Comment PR
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_CI_PR_COMMENT }}
GITHUB_SHA: ${{ github.sha }}
with:
msg: "Commit ${{ github.sha }} deployed"
Where GITHUB_SHA
is the commit to use to find the pull request?
Thank you!
First things first: Nice work on this action, looks great!
I'm building a web application (https://github.com/ActivityWatch/aw-webui) and we take screenshots in our e2e testing that I'd like to show as a comment of each PR. Kinda like how some code coverage services do with their coverage maps.
tl;dr: Is there any way to attach images to the comments? That would be truly awesome.
I have this running on all push events which works great when pushing to a branch with a PR but if there is no PR I just want it to skip. This of course happens on every PR merge where this is a push to master. In my case I still want to run the rest of my action but skip the last step which is posting a comment.
The only option I see to do this cleanly would be to use the if
for the step but that would require somehow duplicating the logic this action is doing to find an associated PR.
Would it make sense to exit(0)
for that case? If that would cause issues for existing users of this action, maybe it could be optional.
It would be lovely if we could trigger comments on pull requests from forks using the newly minted pull_request_target
workflow event. Please let us know if you plan to add this functionality. Thank you!
As a user I would like to be able to add variables to the commit message.
Example:
- name: Comment on PR
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VARIABLE: "Foo"
with:
msg: "Check out this message $VARIABLE!"
check_for_duplicate_msg: false
The exactly same workflow was working in another repository. But is not working now.
https://github.com/Endermanbugzjfc/ExamplePlugin/runs/7337270230?check_suite_focus=true#step:3:156
It will be nice to delete previous message by checking regex. In our case bot is writing commit id base comment. But after another commit there will be another comment. Having so many comments in one repo is extremely not readable on our side. Supporting deleting existing messages by a regex check would be nice.
Is there a way to use environment variables in the msg
?
jobs:
post-url:
name: Comment preview url on PR
runs-on: ubuntu-latest
steps:
- name: comment PR
uses: unsplash/comment-on-pr@master
env:
FIRST_NAME: Mona
BRANCH_NAME: ${GITHUB_REF##*/}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
msg: The branch is ${{ env.BRANCH_NAME }} branch name.
Using env.FIRST_NAME
works fine, but env.BRANCH_NAME
doesn't.
Is there a way to make this work?
Any help is definitely appreciated.
When using this action with uses: unsplash/[email protected]
in a workflow definition, the Docker image has to be built every time the action runs.
If you could provide a finished Docker image off the shelf, action runs would be much faster and possibly more reproducible.
For the time being, I've helped myself with this: https://hub.docker.com/repository/docker/mpdude/comment-on-pr
... which you can use with uses: docker://mpdude/comment-on-pr:v1.2.0
.
But of course it would be much nicer if you could provide this in an "official" way. ๐ป
Hi!
When using this action with the optional parameter check_for_duplicate_msg
, Github Actions logs a warning (see screenshot below).
Code:
- name: Post comment
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
check_for_duplicate_msg: true
msg: Hello
I would like to use this action at the end of my actions on pull requests only if:
enhancement, let me know if you think it makes sense to support.
I forked this repo where I interpret the argument as a filename to read.
Hi, we're using the 1.2.0 tag since it was the last released tag.
This tagged release does not have the check for duplicate functionality.
This also fixes #35 which is the issue we had.
Fix:
All you need to do is release the current code as a tag.
You can do so here:
https://github.com/unsplash/comment-on-pr/releases/new
If you want you can make me a maintainer and I can just release it with the new tag as well.
WARNING: `Faraday::Connection#authorization` is deprecated; it will be removed in version 2.0.
While initializing your connection, use `#request(:authorization, ...)` instead.
See https://lostisland.github.io/faraday/middleware/authentication for more usage info.
/usr/local/bundle/gems/octokit-4.21.0/lib/octokit/response/raise_error.rb:14:in `on_complete': POST https://api.github.com/repos/pushowl/cdn.pushowl.com/issues/650/comments: 403 - Resource not accessible by integration // See: https://docs.github.com/rest/reference/issues#create-an-issue-comment (Octokit::Forbidden)
from /usr/local/bundle/gems/faraday-1.8.0/lib/faraday/middleware.rb:19:in `block in call'
from /usr/local/bundle/gems/faraday-1.8.0/lib/faraday/response.rb:59:in `on_complete'
from /usr/local/bundle/gems/faraday-1.8.0/lib/faraday/middleware.rb:18:in `call'
from /usr/local/bundle/gems/octokit-4.21.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
from /usr/local/bundle/gems/octokit-4.21.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
from /usr/local/bundle/gems/faraday-1.8.0/lib/faraday/request/retry.rb:148:in `call'
from /usr/local/bundle/gems/faraday-1.8.0/lib/faraday/rack_builder.rb:154:in `build_response'
from /usr/local/bundle/gems/faraday-1.8.0/lib/faraday/connection.rb:516:in `run_request'
from /usr/local/bundle/gems/faraday-1.8.0/lib/faraday/connection.rb:281:in `post'
from /usr/local/bundle/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
from /usr/local/bundle/gems/octokit-4.21.0/lib/octokit/connection.rb:156:in `request'
from /usr/local/bundle/gems/octokit-4.21.0/lib/octokit/connection.rb:28:in `post'
from /usr/local/bundle/gems/octokit-4.21.0/lib/octokit/client/issues.rb:284:in `add_comment'
from /entrypoint.sh:68:in `<main>'
Hi,
Thanks for this action!
I am running my workflow on macOS and this doesn't support it, unfortunately. Is there any way to do so? Thanks in advance!
Every time I create a PR I get this error from the the action:
Couldn't find an open pull request for branch with head at .
As soon as I push another commit to the branch it works just fine. Seems it may not be using the correct reference to the head commit of the branch?
The GitAction use like:
Build container for action use: '/runner/_work/_actions/unsplash/comment-on-pr/master/Dockerfile'.
And we have this error bellow:
Step 8/10 : RUN gem install octokit
---> Running in 2853c4253eed
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/bundle directory.
The command '/bin/sh -c gem install octokit' returned a non-zero code: 1
Can you see this error and help us ?
Hey, thanks for the library! Currently using it and it's great.
I use issue_comment
's to trigger GitHub actions and would love to use this library throughout some of these actions. Would it be difficult to add support for issue_comment
's so that the library could comment on the issue that triggered the action?
comment-on-pr
on repository foo/bar
(Repo named bar
of user foo
)john
, fork foo/bar
into john/bar
john
, submit a PR to project foo/bar
/usr/local/bundle/gems/octokit-4.18.0/lib/octokit/response/raise_error.rb:16:
in `on_complete': POST https://api.github.com/repos/foo/bar/issues/1/comments:
403 - Resource not accessible by integration
// See: https://developer.github.com/v3/issues/comments/#create-a-comment
(Octokit::Forbidden)`
I'm trying to set up this GitHub action to comment on PRs using the pull_request_target
trigger so that it works appropriately with forked repository pull requests, but I am getting an error:
Couldn't find an open pull request for branch with head at .
Has anyone successfully used this GitHub Action for commenting on pull requests made with forked repositories and the pull_request_target
trigger?
In my action .yml
file I've got these lines (changed link to be more generic here):
- uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: Example link: [see it here](https://some.link/example-${{ github.event.number }}).
Up until now, this has only posted one comment on my PR and then always updated that comment when I pushed more changes to the PR branch. However, after the latest changes it posts a new comment each time I push a new change to the branch.
Obviously, I'm always getting the latest version of comment-on-pr
via the - uses: unsplash/comment-on-pr@master
when I should perhaps be referring to a specific version... i.e. doing - uses: unsplash/[email protected]
would likely fix this for me, but I'm curious how to fix this while using the latest changes. I couldn't figure that our from reading the code.
It looks like it only deletes the previous (duplicate) comment if I have have a delete_prev_regex_msg
argument? https://github.com/unsplash/comment-on-pr/blob/master/entrypoint.sh#L59
What should the regex be if I simply want to match the previous message? I feel like it's a bit odd to have to provide a regex to delete a duplicate.
@jeffreyguenther made this commit which introduced a regression.
Before the commit this configuration would work as expected:
name: comment-on-pr example
on: pull_request
jobs:
example:
name: sample comment
runs-on: ubuntu-latest
steps:
- name: comment PR
uses: unsplash/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: "Check out this message!"
check_for_duplicate_msg: true
The expectation being: no duplicate "Check out this message!" comment will be posted in the PR if one exists.
However, after the commit, the above configuration WILL ALWAYS post a "Check out this message!" comment even if it already exists on the PR. Please fix this regression because it's really annoying and beats the point of having a check_for_duplicate_msg
configuration in the first place, since it breaks it.
A workaround would be to duplicate the msg
into the new "optional" duplicate_msg_pattern
. The "optional" is in quotes because it's not really optional, it's now required for check_for_duplicate_msg
to work at all.
Getting this error from unsplash/comment-on-pr@master
:
Couldn't find an open pull request for branch with head at .
##[error]Docker run failed with exit code 1
The step trying to use comment-on-pr
looka like this:
- uses: actions/checkout@v1
- name: Comment on zero test changes
uses: unsplash/comment-on-pr@master
if: steps.file_counts.outputs.test_file_count == 0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: >
@${{ github.actor }}
Please add tests.
Would be nice if it was also possible to automatically mark previous comments as outdated that follow a similar pattern as the comment to be posted.
When attempting to use this action to comment on a PR, the following stacktrace is presented:
/usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:14:in `<module:Middleware>': uninitialized constant Faraday::Error::ClientError (NameError)
Did you mean? Faraday::ClientError
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:11:in `<module:Octokit>'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/middleware/follow_redirects.rb:9:in `<top (required)>'
from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit/default.rb:1:in `<top (required)>'
from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/bundle/gems/octokit-4.14.0/lib/octokit.rb:4:in `<top (required)>'
from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `require'
from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
from /entrypoint.sh:4:in `<main>'
/usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- octokit (LoadError)
from /usr/local/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /entrypoint.sh:4:in `<main>'
On subsequent runs of this workflow, the action works. So it seems to only happen on the first pass.
Upgrading to unsplash/[email protected]
causes our builds to fail w/ the following error:
/entrypoint.sh:5:in `require_relative': cannot load such file -- /lib/github (LoadError)
from /entrypoint.sh:5:in `<main>'
Downgrading to unsplash/[email protected]
fixed our builds for now.
Can the package support Github format inside the message?
name: Test writing message in PR
runs-on: ubuntu-latest
steps:
- name: Automation tests run report.
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: |
<details>
<summary>Test Successful Passed</summary>
```
def func():
return 'hello, world!'
```
</details>
check_for_duplicate_msg: true # OPTIONAL
The script should exit (and therefore not add a new comment) if there's a duplicate comment already.
This is done via the check_duplicate_msg
arg which is true
by default. I.e. if this is true
and a duplicate is found, then the script exits.
However, we only check this inside the condition if !duplicate_msg_pattern.empty? || !delete_prev_regex_msg.empty?
, i.e. either one of those arguments has to exist for the script to exit if there's a duplicate. (https://github.com/unsplash/comment-on-pr/blob/master/entrypoint.sh#L43)
Can this be changed so that it checks for duplicates regardless of the duplicate_msg_pattern
and delete_prev_regex_msg
arguments?
See my closed issue #46 for more context for how I got here.
e.g., if you push feature/this-is-my-branch-name
, the Action will fail because "find an open PR" logic is very naive:
Line 24 in a7e9246
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.