1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-23 02:04:34 +02:00

chore: Add action to validate PR titles (#8614)

This commit is contained in:
mister-ben 2024-03-04 17:54:33 +01:00 committed by GitHub
parent d7757d880e
commit 04d10ef3dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 0 deletions

13
.github/actions/pr-titles.js vendored Normal file
View File

@ -0,0 +1,13 @@
const core = require('@actions/core');
const github = require('@actions/github');
(async function run() {
const title = github.context.payload.pull_request?.title;
const titleRegex = /^(chore|ci|docs|feat|fix|refactor|revert|test)(\(.+\))?!?: (.+)/;
if (!!title.match(titleRegex)) {
core.info('Pull request title is OK');
} else {
core.setFailed('Please use conventional commit style for the PR title so the merged change appears in the changelog. See https://www.conventionalcommits.org/.');
}
})();

22
.github/workflows/pr-titles.yml vendored Normal file
View File

@ -0,0 +1,22 @@
name: PR title check
on:
pull_request:
types: [opened, reopened, edited, synchronize]
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
jobs:
pr-title-lint:
name: Should follow conventional commit spec
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm i @actions/core @actions/github
- run: node .github/actions/pr-titles.js