GithubHelp home page GithubHelp logo

Comments (4)

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

Hi @bgilbert

There is only one case where the action causes a pull request to close. That is when there is no longer a diff with the base branch. The action updates the PR branch and when GitHub sees that it has no diff anymore GitHub automatically closes the PR.

If you want to handle this case and add a comment in the PR, this is how I would recommend achieving it.

permissions:
  pull-requests: write

...

      - name: Create Pull Request
        id: cpr
        uses: peter-evans/create-pull-request@v5

      - if: steps.cpr.outputs.pull-request-operation = 'closed'
        uses: peter-evans/create-or-update-comment@v3
        with:
          issue-number: ${{ steps.cpr.outputs.pull-request-number }}
          body: Pull request was closed because there was no longer a diff with the base branch.

from create-pull-request.

bgilbert avatar bgilbert commented on June 3, 2024

That approach sounds reasonable to me, but it currently doesn't work: pull-request-number and pull-request-url aren't set when pull-request-operation is closed.

from create-pull-request.

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

Oh, you're right. 🤦‍♂️

After thinking about this some more, I think this case is not easy to handle in the action because the action only indirectly causes the PR to close. I can't be 100% sure that when the branch is updated it caused the PR to close. A user could have closed it before that and left the branch undeleted. Sorry, but I don't think I have a good solution.

from create-pull-request.

bgilbert avatar bgilbert commented on June 3, 2024

In the updated case, we query the API for the PR corresponding to the head branch. Would it make sense to also do that before deleting the branch, and if a PR is found, put its details in pull-request-{number,url}?

from create-pull-request.

Related Issues (20)

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.