This repository has been archived by the owner on Jan 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
89 lines (82 loc) · 4.23 KB
/
commit-check.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally.
# Contact @moabu
name: 'Commit Message Check'
on:
pull_request:
branches-ignore:
- "update-pycloud-in-**"
types:
- opened
- edited
- reopened
- synchronize
paths:
- "!docker-jans-**/CHANGELOG.md"
- "!docker-jans-**/version.txt"
- "!jans-pycloudlib/CHANGELOG.md"
- "!jans-pycloudlib/jans/pycloudlib/version.py"
pull_request_target:
branches-ignore:
- "update-pycloud-in-**"
types:
- opened
- edited
- reopened
- synchronize
paths:
- "!docker-jans-**/CHANGELOG.md"
- "!docker-jans-**/version.txt"
- "!jans-pycloudlib/CHANGELOG.md"
- "!jans-pycloudlib/jans/pycloudlib/version.py"
push:
branches-ignore:
- "update-pycloud-in-**"
paths:
- "!docker-jans-**/CHANGELOG.md"
- "!docker-jans-**/version.txt"
- "!jans-pycloudlib/CHANGELOG.md"
- "!jans-pycloudlib/jans/pycloudlib/version.py"
jobs:
check-commit-message:
name: Check Commit Message
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v2
with:
# We need to fetch with a depth of 2 for pull_request so we can do HEAD^2
fetch-depth: 2
- uses: actions/[email protected]
with:
node-version: 14
- run: |
npm install --save-dev @commitlint/{config-conventional,cli}
echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js
# If this workflow was triggered by a push then resolve the commit message from HEAD
- name: "[Push] Check Commit Standard"
if: github.event_name == 'push' || github.event_name == 'pull_request_target'
id: push_get_commit_message
run: |
git log --format=%B -n 1 HEAD | npx commitlint |& tee -a output.txt
echo "::set-output name=errormsg::$(tr -d "\n\r" < output.txt)"
git log --format=%B -n 1 HEAD | npx commitlint
continue-on-error: true
# If this workflow was triggered by a pull request (open or synchronize!) then resolve the commit message from HEAD^2
- name: "[Pull Request] Check Commit Standard"
if: github.event_name == 'pull_request'
id: pr_get_commit_message
run: |
git log --format=%B -n 1 HEAD^2 | npx commitlint |& tee -a output.txt
echo "::set-output name=errormsg::$(tr -d "\n\r" < output.txt)"
git log --format=%B -n 1 HEAD^2 | npx commitlint
continue-on-error: true
- name: "[Push] Report Commit Standard Status"
if: steps.push_get_commit_message.outcome != 'success' && github.event_name == 'push'
run: |
curl -X POST -H 'Content-Type: application/json' --data '{"alias":"Mo-Auto","emoji":":robot:","text":":x: :cry: I am reporting a bad [commit](https://github.com/${{github.repository}}/commit/${{github.sha}}) by :thinking_face: @${{github.actor}} :x:","attachments":[{"title":"GitHub user behavior reporter","title_link":"https://www.conventionalcommits.org","text":"We are not too happy with your last [commit](https://github.com/${{github.repository}}/commit/${{github.sha}}). Here is why : ${{ steps.push_get_commit_message.outputs.errormsg }}","color":"#764FA5"}]}' ${{ secrets.GITHUBUSERBEHAVIORROCKETCHATREPORTER }}
exit 1
- name: "[Pull Request] Report Commit Standard Status"
if: steps.pr_get_commit_message.outcome != 'success' && github.event_name == 'pull_request'
run: |
curl -X POST -H 'Content-Type: application/json' --data '{"alias":"Mo-Auto","emoji":":robot:","text":":x: :cry: I am reporting a bad [commit](https://github.com/${{github.repository}}/tree/${{github.head_ref}}) by :thinking_face: @${{github.actor}} :x:","attachments":[{"title":"GitHub user behavior reporter","title_link":"https://www.conventionalcommits.org","text":"We are not too happy with your last commit merging into https://github.com/${{github.repository}}/tree/${{github.base_ref}}. Here is why : ${{ steps.pr_get_commit_message.outputs.errormsg }}","color":"#764FA5"}]}' ${{ secrets.GITHUBUSERBEHAVIORROCKETCHATREPORTER }}
exit 1