-
-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support commenting on a PR when closing it #2415
Comments
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. |
That approach sounds reasonable to me, but it currently doesn't work: |
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. |
In the |
Subject of the issue
create-pull-request doesn't comment on a PR when closing it. While it's possible to infer why the PR was closed, it'd be great if there were a way to configure some comment text to post to the PR.
The text was updated successfully, but these errors were encountered: