PR Template Check #175
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: PR Template Check | |
| on: | |
| pull_request: | |
| types: [opened, edited, synchronize] | |
| merge_group: | |
| jobs: | |
| check-template: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Verify PR body contains Checklist section | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| if (context.eventName === 'merge_group') { | |
| core.info('Merge group event — template already checked on the PR'); | |
| return; | |
| } | |
| const author = context.payload.pull_request.user.login; | |
| const { data: perm } = await github.rest.repos.getCollaboratorPermissionLevel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| username: author, | |
| }).catch(() => ({ data: null })); | |
| const level = perm?.permission; | |
| core.info(`PR author: ${author}, repo permission: ${level}`); | |
| if (level === 'admin' || level === 'write') { | |
| core.info(`Skipping checklist check for repo ${level}`); | |
| return; | |
| } | |
| const body = context.payload.pull_request.body || ''; | |
| if (!body.includes('## Checklist')) { | |
| core.setFailed( | |
| 'PR body is missing the "## Checklist" section. ' + | |
| 'Please use the PR template when opening a pull request.' | |
| ); | |
| } |