-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3312ffe
commit e6b5ba6
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: PR Validation and Comment Bot | ||
|
||
# Trigger the workflow on pull request creation | ||
on: | ||
pull_request: | ||
types: [opened] | ||
|
||
jobs: | ||
check_branch: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check if PR is from main or master | ||
run: | | ||
if [[ "${{ github.event.pull_request.head.ref }}" == "main" || "${{ github.event.pull_request.head.ref }}" == "master" ]]; then | ||
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ | ||
-d '{"body": "### :warning: Warning: Please create a new branch!\n\nIt looks like your pull request is based on the `main` or `master` branch. To keep the repository organized and avoid conflicts, please follow these steps:\n\n1. Close this PR.\n2. Create a new branch using `git checkout -b your-branch-name`.\n3. Make your changes in that branch and open a new PR.\n\nThank you!"}' | ||
exit 1 | ||
fi | ||
- name: Comment on valid PR | ||
if: ${{ success() }} | ||
run: | | ||
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ | ||
-d '{"body": "### Thank you for opening a Pull Request!\n\nYour contribution is highly appreciated. Please make sure your PR meets the following guidelines:\n\n1. Follow our [contribution guidelines](https://link-to-guidelines).\n2. Ensure all code is properly documented.\n3. Add tests for your new code if applicable.\n\nThank you for your contribution!"}' |