This is an GitHub Action, use to ensure your PR format is acceptable.
if PR didn't pass your check, the merge request will be blocked.
Put URGENT into PR title to skip this check.
edit .github/workflows/pr-check.yml
name: Check Pr
on:
pull_request:
types:
- opened
- reopened
- edited
jobs:
check-pr:
runs-on: ubuntu-latest
steps:
- uses: UrbanCompass/prchecker@main
with:
skip-word: "URGENT" # optional, this is default value
exempt-users: '["sobadgirl", "alex"]' # optional, serialized json array of GitHub user name(not display name). fill this field when you want some people to be exempt from this pr checker.
check-items: "all" # optional JSON array string of check items or 'all', default 'all'. example: '["body", "tasks", "xxx"]', all items can found in `src/checks.js`
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
When only select some check items, just update lines like below:
...
jobs:
check-pr:
steps:
- uses: UrbanCompass/prchecker@main
check-items: '["body", "jiraTitle", "tasks"]' # this line changed, items are function names in ./src/checks.js:checkers
yaml
array? That because input of GitHub Action only support string.
also see references:
This project was write with js
.
You should setup nodejs
development environment, we especially suggest use NVM, install it by run:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
then install and use nodejs
via NVM:
nvm install --lts
nvm use --lts
Ensure you got nodejs
successfully installed.
$ node -v
v17.3.0
Clone this repository:
git clone [email protected]:UrbanCompass/prchecker.git
install npm dependencies
npm i
add a new check function (pr: Object): CheckResult
in src/checks.js
, param pr
is context data, payload is: https://docs.github.com/en/rest/reference/pulls#get-a-pull-request
don't forget to run npm run all
before you commit and push.
npm run all
git add .
git commit -m "some changes"
git push origin your-branch
run locally: brew install act
- checker function support return more info, not only
true
orfalse
- custom word for SKIP
- read check items input
- custom failure message from input
- changed lines exclude testing
- auto release
- version lock
- testing