Skip to content
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

Add PR auto-approve option #24

Merged
merged 2 commits into from
Oct 17, 2020
Merged

Add PR auto-approve option #24

merged 2 commits into from
Oct 17, 2020

Conversation

R0Wi
Copy link
Contributor

@R0Wi R0Wi commented Oct 10, 2020

Problem:
Personally i use Github branch protection rules to prevent merging into stable and master-branches without a pull request review. This prevents the fork-sync action to automatically merge the changes of the forked repository into my personal fork. Generally speaking i don't want to change the branch-protection-rules because when talking about regular code-changes these make perfectly sense to me.

What this change implements:
This PR adds a new feature "auto-approve" which can be activated optionally by setting auto_approve and personal_token input variables. After the pull request is created by the fork-sync action the auto_approve variable will be checked. If it's set to true the action will approve the changes made by the pull request created before with the user which belongs to the personal_token. Also a comment on this review will be generated which makes it clear that this review was automatically generated. Afterwards the github-actions bot is able to merge the pull request.

A possible result will look like this:
image

This changes solves:
Branch protection rules regarding the review process can exist next to the fok-sync action.

Also in this PR:
When testing i noticed that there was a situation where an error occured and error.errors was set and contained one element which had no message property so i received Cannot read property 'startsWith' of undefined.

if (!!error.errors && error.errors[0].message.startsWith('No commits between')) {

I improved this, too.

Let me know what you think about this

Cheers :-)

@tgymnich tgymnich self-requested a review October 11, 2020 12:46
base: master
head: master
auto_approve: true
personal_token: ${{ secrets.PERSONAL_TOKEN }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the already used GITHUB_TOKEN have sufficient permissions to review and approve PRs?

Copy link
Contributor Author

@R0Wi R0Wi Oct 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it but Github gave me an error message like "you cannot approve your own pull request" which makes sense somehow ;-)

So there have to be two different users then

Copy link
Owner

@tgymnich tgymnich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants