Skip to content

Commit 5f54b03

Browse files
authored
chore: workflows (#12)
1 parent 36cd678 commit 5f54b03

File tree

5 files changed

+123
-1
lines changed

5 files changed

+123
-1
lines changed

.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/lint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
lint:
9+
runs-on: buildjet-4vcpu-ubuntu-2204
10+
container:
11+
image: node:22
12+
credentials:
13+
username: ${{ vars.DOCKER_HUB_USERNAME }}
14+
password: ${{ secrets.DOCKER_HUB_API_KEY }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: pnpm setup
19+
uses: pnpm/action-setup@v4
20+
- name: Setup Node
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
cache: "pnpm"
25+
- name: Install packages
26+
run: pnpm install
27+
- name: Run Lint
28+
run: pnpm lint
29+
env:
30+
SKIP_ENV_VALIDATION: true
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Pin Dependencies Check
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
pin-dependencies-check:
9+
runs-on: buildjet-4vcpu-ubuntu-2204
10+
container:
11+
image: node:22
12+
credentials:
13+
username: ${{ vars.DOCKER_HUB_USERNAME }}
14+
password: ${{ secrets.DOCKER_HUB_API_KEY }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Check for pinned dependencies
19+
run: |
20+
node -e '
21+
const fs = require("fs");
22+
const pkg = JSON.parse(fs.readFileSync("package.json", "utf8"));
23+
const errors = [];
24+
25+
function isPinned(version) {
26+
return /^\d+\.\d+\.\d+(-canary\.\d+)?$/.test(version);
27+
}
28+
29+
for (const [dep, version] of Object.entries(pkg.dependencies || {})) {
30+
if (!isPinned(version)) {
31+
errors.push(`Dependency "${dep}" is not pinned: "${version}"`);
32+
}
33+
}
34+
35+
for (const [dep, version] of Object.entries(pkg.devDependencies || {})) {
36+
if (!isPinned(version)) {
37+
errors.push(`Dev dependency "${dep}" is not pinned: "${version}"`);
38+
}
39+
}
40+
41+
if (errors.length > 0) {
42+
console.error(`\n${errors.join("\n")}\n`);
43+
process.exit(1);
44+
} else {
45+
console.log("All dependencies are pinned.");
46+
}
47+
'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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:22
10+
credentials:
11+
username: ${{ vars.DOCKER_HUB_USERNAME }}
12+
password: ${{ secrets.DOCKER_HUB_API_KEY }}
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
- name: Run PR title check
17+
run: |
18+
node .github/scripts/pr-title-check.js

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"@cloudflare/workers-types": "4.20250604.0",
1616
"@types/react": "19.1.6",
1717
"wrangler": "4.19.1"
18-
}
18+
},
19+
"packageManager": "[email protected]"
1920
}

0 commit comments

Comments
 (0)