first-contributions
first-contributions copied to clipboard
Implement Github Action auto-merge PR script with error handling and descriptive messages - (reference to #68620)
Auto-Merge Contributors.md Changes in response to issue https://github.com/firstcontributions/first-contributions/issues/68620
This PR adds an automated process to merge pull requests that only modify the Contributors.md
file. If changes are detected in this file, the PR will be automatically merged using the squash method. If changes are detected in other files, a comment will be posted indicating that the PR requires review.
Changes Made
- Added workflow script to automate the merging of pull requests.
-
- Success case example (Merged PR) -> Success case - Auto merge PR (Github Action runner) and Success PR post
-
- A case when PR has changed to
Contributors.md
and other files -> Failure case - Fail to auto-merge PR due to changes to other files (Github Action runner) and PR post
- A case when PR has changed to
- Trigger workflow when
Contributors.md
file changes and checked if the pull request only modifies theContributors.md
file. - Merged the pull request automatically if it meets the criteria -> code.
- Posted a comment on the pull request if it was not merged automatically (due to PR having changes to
Contributors.md
and other file, indicating that it requires review. check code and result.
How to Test
Note: The workflow will only run if the
Contributors.md
file is modified. If there are no changes to this file, the workflow will not be triggered and will be ignored.
Auto merge
- Create a new pull request that modifies the
Contributors.md
file only. - Ensure that the pull request meets the criteria for automatic merging.
- Observe that the pull request is automatically merged using the squash merge method.
- Verify that the pull request was successfully merged.
Do not Auto merge (Hold for review)
- Create a new pull request that modifies additional files besides
Contributors.md
. - Observe that the pull request is not automatically merged.
- Check the pull request comments for a message indicating that the PR requires review.
Types of Pull Requests and Messages
- Type 1: Pull requests modifying only the Contributors.md file:
Success preview message
Hello @Esh07, congratulations! You've successfully submitted a pull request. 🎉 Thanks for your contribution!If you liked the tutorial, please star this repo by clicking the star button on the top right of this page.
Next steps
Continue contributing:
- If you're looking for projects to contribute to, check out our web app webapp.
- Join our Slack group: We have a community to help/support contributors. Slack Join slack group.
- Share on social media: You can share this content to help more people. Twitter tweet. Facebook share
- We'd love to hear your thoughts about this project. Let us know how we can improve by commenting or opening an issue here
-
Type 2: Pull requests modifying additional files besides Contributors.md:
- Message: "Thank you for your pull request. This pull request contains changes in files that require review. The following files were changed:
- [List of changed files] "
- Message: "Thank you for your pull request. This pull request contains changes in files that require review. The following files were changed:
Please review and merge this PR if everything looks good.
@Roshanjossey The requested changes are now live and implemented. Cheers.
Thank you for adding this @Esh07. Great job.