Labels and checks PR title and body, and verifies commit style from branches and Github squashed merges.
The mou-pr-action
commits for mou-pr-action
.
Create a step on pull_request
or push
events. This action can be run in
different ways.
To check commit messages (PR operations will be ignored):
name: 'commit'
"on":
push:
jobs:
check:
name: check commit style
runs-on: ubuntu-latest
steps:
- name: Checkout git repository
uses: actions/checkout@v1.2.0
- name: Check commits
uses: minddocdev/mou-pr-action@master
with:
commitTitleLength: 72
conventionalCommits: true
token: ${{ github.token }}
To check PR style and label based on file globs
name: 'pr'
"on":
pull_request:
jobs:
check:
name: check PR style
runs-on: ubuntu-latest
steps:
- name: Checkout git repository
uses: actions/checkout@v1.2.0
- name: Check PR style and add PR labels
uses: minddocdev/mou-pr-action@master
with:
prTitleLength: 50
prTitleRegex: \[(JIRA-[0-9]+|CHORE|HOTFIX)\] [A-Za-z0-9]+$'
labels: |
"build":
- "**/Makefile"
- "**/tsconfig.json"
- "**/tsconfig.*.json"
- "**/vue.config.js"
"ci": ".github/**"
Both operations can do at the same time if both events are defined in the same workflow:
name: 'pr'
"on":
pull_request:
push:
jobs:
check:
name: check PR and commit style
runs-on: ubuntu-latest
steps:
- name: Checkout git repository
uses: actions/checkout@v1.2.0
- name: Check commit/PR style and add PR labels
uses: minddocdev/mou-pr-action@master
with:
commitTitleLength: 72
commitTitleRegex: '^(?:fixup!\s*)?(\w*)(\(([\w\$\.\*/-]*)\))?\: (.*)$'
prTitleLength: 50
prTitleRegex: '\[(JIRA-[0-9]+|CHORE|HOTFIX)\] [A-Za-z0-9]+$'
labels: |
"build":
- "**/Makefile"
- "**/tsconfig.json"
- "**/tsconfig.*.json"
- "**/vue.config.js"
"ci": ".github/**"
- name: commitTitleLength
- required: false
- description: The maximum line length for the commit title. e.g.
72
.
- name: commitTitleRegex
- required: false
- description: The regex that should validate the commit title.
e.g.
'^(?:fixup!\s*)?(\w*)(\(([\w\$\.\*/-]*)\))?\: (.*)$'
- name: conventionalCommits
- required: false
- default:
false
- description: Check for conventional style commits. See conventional commits
- name: labels
- required: false
- description: The YAML or JSON map of labels with the list of file matchers. e.g:
label1:
- example/**/*
- name: prBodyRegex
- required: false
- description: The regex that should validate the PR body.
e.g.
'^.+(Closes|Fixes): \[(JIRA-[0-9])\]$'
- name: prTitleLength
- required: false
- description: The maximum line length for the PR title. e.g.
50
.
- name: prTitleRegex
- required: false
- description: The regex that should validate the PR title.
e.g.
'\[(JIRA-[0-9]+|CHORE|HOTFIX)\] [A-Za-z0-9]+$'
- name: token
- required: true
- description: The token to access Github's API.
Install dependencies
yarn
Compile typescript
yarn build
Lint code
yarn lint
Run the tests
yarn test