GithubHelp home page GithubHelp logo

Comments (4)

peter-evans avatar peter-evans commented on July 3, 2024

Hi @mpdude

Does github.head_ref work for you? I've not tried it but I would be surprised if that works. The GitHub API is expecting a commit SHA, not a ref.

Even if it works, I think it might be more correct to use github.event.pull_request.head.sha instead. I know this works because I use it in my CI build. See here

Anyway, it's a good idea to add something to the readme about this. I'll add a section to explain about avoiding the merge commit.

from commit-comment.

peter-evans avatar peter-evans commented on July 3, 2024

I just checked and using head_ref does work because the API is converting the ref into the "last sha on the ref." There is a small risk that you will hit the wrong commit sha though. If another commit is pushed to the branch before the action runs it will add the comment to the latest commit SHA, not the commit SHA that the Actions run is executing on.

from commit-comment.

peter-evans avatar peter-evans commented on July 3, 2024

I don't think anyone would ever want to add a comment to the merge commit, so I'm now thinking of updating the action to detect that it is running on a pull_request event and just defaulting the SHA to the pull request branch HEAD.

from commit-comment.

peter-evans avatar peter-evans commented on July 3, 2024

Updated v1 to default sha to the branch HEAD on pull request events.

from commit-comment.

Related Issues (9)

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.