Skip to content

Commit

Permalink
setup a bot for PR validation
Browse files Browse the repository at this point in the history
  • Loading branch information
poorvikaa08 committed Oct 8, 2024
1 parent 3312ffe commit e6b5ba6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/PR_message.yml
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!"}'

0 comments on commit e6b5ba6

Please sign in to comment.