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 pull request template + compliance check action #5915

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
# STOP! Read this before submitting your pull request

## ⚠️ Warning ⚠️
This repository is not for educational exercises or trivial changes. Pull requests that do not provide substantial value will be closed immediately.

Before submitting your pull request, make sure you answer YES to ALL of the following (replace each "[ ]" with "[x]" - if any do not apply, do not create the pull request):
-->

## Checklist

- [ ] I have read and understood the contributing guidelines
- [ ] This pull request addresses an existing issue or adds significant functionality
- [ ] I have tested my changes thoroughly
- [ ] My commit messages are clear and descriptive
- [ ] I am NOT submitting this as part of a coding course or tutorial

## Confirmation
By submitting this pull request, I confirm that:
- [ ] This is NOT a trivial change (e.g., simple README updates)
- [ ] I understand that misuse of this repository may result in being blocked

## Description
<!-- Please provide a clear and concise description of your changes: -->

## Related Issue
<!-- If this PR addresses an existing issue, please link to it: -->

<!--
**Note: Pull requests that do not fill out this template completely and honestly will be closed without review.**
-->
43 changes: 43 additions & 0 deletions .github/workflows/pr-compliance-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Pull Request Compliance Check

on:
pull_request_target:
types: [opened, edited, synchronize, reopened]

jobs:
check-pr-compliance:
runs-on: ubuntu-latest
steps:
- name: Check PR body
id: check_pr_body
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const prBody = context.payload.pull_request.body;
const requiredChecks = [
'- [x] This is NOT a trivial change',
'- [x] I understand that misuse of this repository may result in being blocked',
'- [x] I am NOT submitting this as part of a coding course or tutorial',
];

const missingChecks = requiredChecks.filter(check => !prBody.includes(check));

if (missingChecks.length) {
console.log(`Pull request is not compliant. Missing checks:`, missingChecks);
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'This pull request does not comply with our submission guidelines. It will be automatically closed. Please read our contributing guidelines carefully before submitting a new pull request.'
});

github.rest.pulls.update({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
});
} else {
console.log(`Pull request is compliant`);
}