-
Notifications
You must be signed in to change notification settings - Fork 14
85 lines (71 loc) · 2.64 KB
/
Copy pathguidelines-compliance.yml
File metadata and controls
85 lines (71 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Guidelines Compliance
on:
pull_request:
types: [ opened, edited, synchronize, reopened ]
permissions:
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
validate-pr-title:
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
- name: Install commitlint
run: |
npm install --save-dev @commitlint/cli @commitlint/config-conventional
- name: Create commitlint config
run: |
echo "module.exports = { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
- name: Validate PR title
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
echo $PR_TITLE | npx commitlint
- name: Comment on PR if validation fails
if: failure()
uses: actions/github-script@v8
with:
script: |
const comment = `❌ **PR Title Validation Failed**
Please refer to [CONTRIBUTING.md](https://github.com/ozontech/seq-db/blob/main/.github/CONTRIBUTING.md)`;
github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
validate-branch-name:
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Validate branch name
id: validate-branch
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
run: |
# Pattern: {issue-number}-{branch-name}
# Issue number must be 0 or positive integer
BRANCH_PATTERN="^(0|[1-9][0-9]*)-[a-z0-9]+(-[a-z0-9]+)*$"
if [[ ! "$BRANCH_NAME" =~ $BRANCH_PATTERN ]]; then
echo "validation_failed=true" >> $GITHUB_OUTPUT
exit 1
fi
- name: Comment on PR if validation fails
if: failure()
uses: actions/github-script@v8
with:
script: |
const comment = `❌ **Branch Name Validation Failed**
Please refer to [CONTRIBUTING.md](https://github.com/ozontech/seq-db/blob/main/.github/CONTRIBUTING.md)`;
github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});