-
Notifications
You must be signed in to change notification settings - Fork 35
51 lines (51 loc) · 1.49 KB
/
check_commits.yaml
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
---
name: Check Commit
on: pull_request
jobs:
single_commit:
name: Assert single commit
if: github.base_ref == 'main'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 30
- name: Checkout main
run: git fetch origin main
- name: create local main branch
run: git branch main origin/main
- name: Commit Count Check
run: test `git log --oneline --no-merges HEAD ^main | wc -l ` = 1
runs-on: ubuntu-latest
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
git fetch --prune --unshallow
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install python dependencies
run: |
pip install requests j2cli PyGithub
- name: Generate the validation script
shell: bash
run: |
cd templates
issue_tracker=github plugin_name=plugin_template j2 --undefined github/.ci/scripts/validate_commit_message.py.j2 > ../validate_commit_message.py
cd ..
- name: Check commit message
env:
GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }}
run: |
for sha in $(curl $GITHUB_CONTEXT | jq '.[].sha' | sed 's/"//g')
do
python validate_commit_message.py $sha
VALUE=$?
if [ "$VALUE" -gt 0 ]; then
exit $VALUE
fi
done
shell: bash