Skip to content

Commit 4b9cd60

Browse files
committed
add CI
1 parent bae5b84 commit 4b9cd60

3 files changed

Lines changed: 63 additions & 0 deletions

File tree

.github/scripts/pr-title-check.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import fs from 'node:fs';
2+
3+
const eventPath = process.env.GITHUB_EVENT_PATH;
4+
const eventJson = JSON.parse(fs.readFileSync(eventPath, 'utf8'));
5+
const prTitle = eventJson.pull_request.title;
6+
7+
const isValidType = (title) =>
8+
/^(feat|fix|chore|refactor)(\([a-zA-Z0-9-]+\))?:\s[a-z].*$/.test(title);
9+
10+
const validateTitle = (title) => {
11+
if (!isValidType(title)) {
12+
console.error(
13+
`PR title does not follow the required format.
14+
example: "feat: add webhooks filter"
15+
16+
- type: "feat", "fix", "chore", or "refactor"
17+
- First letter of the PR title needs to be lowercased
18+
`,
19+
);
20+
process.exit(1);
21+
}
22+
23+
console.info('PR title is valid');
24+
};
25+
26+
validateTitle(prTitle);

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Build
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
build:
9+
runs-on: buildjet-4vcpu-ubuntu-2204
10+
container:
11+
image: node:24
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: pnpm setup
16+
uses: pnpm/action-setup@v4
17+
with:
18+
version: 10.20.0
19+
- name: Install packages
20+
run: pnpm install
21+
- name: Run Build
22+
run: pnpm build
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: PR Title Check
2+
on:
3+
pull_request:
4+
types: [opened, edited, synchronize]
5+
jobs:
6+
pr-title-check:
7+
runs-on: buildjet-4vcpu-ubuntu-2204
8+
container:
9+
image: node:24
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- name: Run PR title check
14+
run: |
15+
node .github/scripts/pr-title-check.js

0 commit comments

Comments
 (0)