This repository has been archived by the owner on Aug 28, 2023. It is now read-only.
Update README.md #808
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
name: "Check Pull Request Name" | |
on: [pull_request, push] | |
jobs: | |
pr-name-check: | |
name: Check Pull Request Name | |
runs-on: ubuntu-20.04 | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Compare PR Name to the Template | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
const prName = context.payload.pull_request.title; | |
const prCreator = context.payload.pull_request.user.login; | |
const prNameRegExp = /^(?:\[\d+\]\s)+\w+.*/; | |
const skipLabel = '[skip-name]'; | |
console.log(`Pull Request Name is ${prName}`); | |
// Skip the PRs with dependency updates | |
const dependencyBotsNames = ['dependabot', 'snyk-bot']; | |
const shouldSkip = prName.includes(skipLabel) || dependencyBotsNames.includes(prCreator); | |
if (shouldSkip) { | |
console.log('Skipping PR name checks.'); | |
return; | |
} | |
if (!prNameRegExp.test(prName)) { | |
console.log('Template: [issue_number] ([another_issue_number] ...) Short description'); | |
core.setFailed('Your Pull Request title does not confirm to the template.'); | |
return; | |
} | |
console.log('Your Pull Request name confirm to the provided template.'); |