fix: improve student management validation and security #1
Workflow file for this run
This file contains hidden or 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
| name: Prashant's PR Checker Bot | |
| on: | |
| pull_request: | |
| types: [opened, edited] | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Validate PR | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const pr = context.payload.pull_request; | |
| const body = pr.body || ''; | |
| let problems = []; | |
| // Check 1: Is an issue linked? | |
| if (!body.match(/(?:fixes|closes|resolves)\s#(\d+)/i)) { | |
| problems.push('❌ No issue linked — please write `Fixes #ISSUE_NUMBER` in your description'); | |
| } | |
| // Check 2: Is there a proper description? | |
| if (body.trim().length < 20) { | |
| problems.push('❌ PR description is too short — please add more details'); | |
| } | |
| if (problems.length > 0) { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number, | |
| body: `Hey @${pr.user.login}! Please fix the following before this PR can be reviewed:\n\n${problems.join('\n')}` | |
| }); | |
| } else { | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number, | |
| labels: ['ready-for-review'] | |
| }); | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: pr.number, | |
| body: `✅ Everything looks good @${pr.user.login}! Your PR is ready for review.` | |
| }); | |
| } |