Skip to content

Commit 93ac8cb

Browse files
authored
ci: [WPN-4] CI is not getting triggered (#8)
* ci: [3] Test CI workflow * ci: [WPN-4] CI is not getting triggered * test: this is a test * test: this is a test * test: this is a test * test: this is a test * test: this is a test
1 parent 40316f2 commit 93ac8cb

2 files changed

Lines changed: 51 additions & 44 deletions

File tree

Lines changed: 10 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,18 @@
1-
name: CI
1+
name: Package Validity
22

33
on:
44
push:
5-
branches: [main]
5+
branches: ["master"]
6+
paths:
7+
- "packages/**"
8+
- ".github/workflows/package-ci.yml"
69
pull_request:
7-
branches: [main]
10+
branches: ["master"]
11+
paths:
12+
- "packages/**"
13+
- ".github/workflows/package-ci.yml"
814

915
jobs:
10-
pr-title-check:
11-
name: PR Title Check
12-
runs-on: ubuntu-latest
13-
if: github.event_name == 'pull_request'
14-
steps:
15-
- name: Check PR Title
16-
uses: actions/github-script@v7
17-
with:
18-
script: |
19-
const title = context.payload.pull_request.title;
20-
const pattern = /^(feat|fix|bug|doc|ci|release|test): \[(WPN-[0-9]+(, WPN-[0-9]+)*)\] [A-Z].+$/;
21-
22-
if (!pattern.test(title)) {
23-
const validTypes = ['feat', 'fix', 'bug', 'doc', 'ci', 'release', 'test'];
24-
const examples = [
25-
'feat: [WPN-1] Implement user authentication',
26-
'fix: [WPN-42] Fix memory leak in notification service',
27-
'doc: [WPN-7, WPN-8] Update API documentation',
28-
'ci: [WPN-15] Add performance testing to pipeline'
29-
];
30-
31-
core.setFailed(`
32-
PR title does not match the required pattern!
33-
34-
Required format: <type>: [<issue-number>] <title>
35-
36-
Where:
37-
- type: Must be one of: ${validTypes.join(', ')}
38-
- issue-number: Must be WPN-X or multiple like [WPN-1, WPN-2]
39-
- title: Must start with a capital letter
40-
41-
Valid examples:
42-
${examples.map(ex => `- ${ex}`).join('\n ')}
43-
44-
Your title: "${title}"
45-
`);
46-
} else {
47-
console.log('✅ PR title format is valid!');
48-
}
49-
5016
lint-format:
5117
name: Lint & Format
5218
runs-on: ubuntu-latest
@@ -156,4 +122,4 @@ jobs:
156122
run: pnpm install --frozen-lockfile
157123

158124
- name: Build packages
159-
run: pnpm -r build
125+
run: pnpm build

.github/workflows/verify-pr.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Verify PRs
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, edited]
6+
7+
jobs:
8+
pr-title-check:
9+
name: PR Title Check
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check PR Title
13+
shell: bash
14+
env:
15+
PR_TITLE: ${{ github.event.pull_request.title }}
16+
run: |
17+
echo "Checking PR title: $PR_TITLE"
18+
19+
# Define valid types
20+
VALID_TYPES="feat|fix|bug|doc|ci|release|test"
21+
22+
# Regular expression pattern for PR title validation
23+
if ! [[ "$PR_TITLE" =~ ^($VALID_TYPES):[[:space:]]\[(WPN-[0-9]+(,[[:space:]]*WPN-[0-9]+)*)\][[:space:]][A-Z].* ]]; then
24+
echo "::error::PR title does not match the required pattern!"
25+
echo "::error::Required format: <type>: [<issue-number>] <title>"
26+
echo "::error::Where:"
27+
echo "::error::- type: Must be one of: feat, fix, bug, doc, ci, release, test"
28+
echo "::error::- issue-number: Must be WPN-X or multiple like [WPN-1, WPN-2]"
29+
echo "::error::- title: Must start with a capital letter"
30+
echo "::error::"
31+
echo "::error::Valid examples:"
32+
echo "::error::- feat: [WPN-1] Implement user authentication"
33+
echo "::error::- fix: [WPN-42] Fix memory leak in notification service"
34+
echo "::error::- doc: [WPN-7, WPN-8] Update API documentation"
35+
echo "::error::- ci: [WPN-15] Add performance testing to pipeline"
36+
echo "::error::"
37+
echo "::error::Your title: \"$PR_TITLE\""
38+
exit 1
39+
else
40+
echo "✅ PR title format is valid!"
41+
fi

0 commit comments

Comments
 (0)