-
Notifications
You must be signed in to change notification settings - Fork 456
74 lines (63 loc) · 2.35 KB
/
ga-misc-check-compliance.yml
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
name: 📋 Check PR Compliance
on:
pull_request:
types:
[
opened,
edited,
synchronize,
reopened,
labeled,
unlabeled,
assigned,
unassigned,
]
jobs:
check-pr-compliance:
name: ✅ Check PR for Compliance
runs-on: ubuntu-latest
steps:
- name: 🐧 Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🏷️ Show PR Labels and Assignees
run: |
echo "PR Labels: ${{ toJson(github.event.pull_request.labels) }}"
echo "PR Assignees: ${{ toJson(github.event.pull_request.assignees) }}"
- name: 🙋 Verify PR Assignee
run: |
if [ "${{ toJson(github.event.pull_request.assignees) }}" == "[]" ]; then
echo "👮 This PR does not have any assignees. Please assign at least one assignee."
exit 1
fi
- name: 🏷️ Verify PR Label
run: |
if [ "${{ toJson(github.event.pull_request.labels) }}" == "[]" ]; then
echo "👮 This PR does not have any labels. Please assign at least one label."
exit 1
fi
- name: 📝 Check Commit Messages
id: check_commits
run: |
#!/bin/bash
set -e
BASE_SHA=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
COMMITS=$(git log --pretty=format:"%s" $BASE_SHA..${{ github.event.pull_request.head.sha }})
INVALID_COMMITS=()
while IFS= read -r commit; do
if ! [[ $commit =~ ^(add|delete|update|fix|bump|security|refactor|style|test|docs|chore|perf|ci|build|revert)(\([a-z]+\))?:\ .+ ]]; then
INVALID_COMMITS+=("$commit")
fi
done <<< "$COMMITS"
if [ ${#INVALID_COMMITS[@]} -ne 0 ]; then
echo "👮 Warning: The following commits do not follow the 01-edu commit message convention:"
for commit in "${INVALID_COMMITS[@]}"; do
echo " - $commit"
done
echo " 📢 Please consider updating your commit messages to follow the standard: https://github.com/01-edu/conventions/"
exit 1
else
echo "✅ All commit messages follow the 01-edu convention."
fi
continue-on-error: true