Giter VIP home page Giter VIP logo

comment-on-pr's People

Contributors

aaronklaassen avatar baldoalessandro avatar connorads avatar erdnaxeli avatar jeffreyguenther avatar kenke7 avatar lmammino avatar mangelarilla avatar mpdude avatar patrickeasters avatar sadikkuzu avatar sarink avatar suryasr007 avatar thetorpedodog avatar timmycarbone avatar tobloef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

comment-on-pr's Issues

Does not work when called from a fork

  1. Install comment-on-pr on repository foo/bar (Repo named bar of user foo)
  2. As user john, fork foo/bar into john/bar
  3. As user john, submit a PR to project foo/bar
  4. Failure
/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)`

Provide a ready-to-go Docker image

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. ๐Ÿป

Feature request: Attaching image to comment

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.

Script is not exiting when there's a duplicate comment unless either regex arg is provided

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.

Failure when is build container with GitAction

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 ?

Octokit 'cannot load file'

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.

Multiple commits move HEAD during Github Actions

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!

How to delete duplicate comments with latest changes (v.1.3.0)?

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.

Can we update the tag please?

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.

Regression introduced in commit 9aac0ab: check_for_duplicate_msg now broken, duplicate_msg_pattern is non-optional

@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.

Unable to comment on PR created by a dependabot

  1. I have a workflow that runs when a PR is created by any user. This workflow works fine.
  2. But when a PR is created by Dependabot the github action fails. It fails with following error
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>'
  1. When I trigger the workflow again manually for that PR it succeeds
  2. Is this some permission issue ?

Support github format inside the message?

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

Can environment variables be used in msg?

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.

Always fails when opening a PR

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?

Don't fail if no PR Exists (optionally?)

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.

Check if the pr's author is some user?

I would like to use this action at the end of my actions on pull requests only if:

  • the author of the pull request is dependabot so I can tell it to merge using the action.
  • the author is someone else tell them some other things.

Builds failing with v1.3.1

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.

Add support for ENV variables

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

Support deleting previous message by regex

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.

"Couldn't find an open pull request for branch with head at ."

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.

Can't find open pull request when using pull_request_target

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?

How to run this on macOS-latest?

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!

[feature-request] - Support issue_comment triggers

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?

Mark previous comments as outdated

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.

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.