Imported Upstream version 1.19.0
[platform/core/ml/nnfw.git] / .github / workflows / check-pr-commit.yml
1 name: Check PR commit
2
3 on:
4   pull_request:
5     branches:
6       - master
7       - release/*
8
9 defaults:
10   run:
11     shell: bash
12
13 jobs:
14   check-commit-message:
15     name: Check commit message
16     runs-on: ubuntu-20.04
17
18     steps:
19       - name: Checkout
20         uses: actions/checkout@v2
21         with:
22           # Checkout PR head commit
23           # Checkout Action use merge commit as default
24           ref: ${{ github.event.pull_request.head.sha }}
25           # Fetch all history and branch (default: 1)
26           fetch-depth: 0
27
28       - name: Get commit body
29         run: |
30           git log origin/${GITHUB_BASE_REF}..HEAD --format=%b > commit_msg.txt
31           sed '/^$/d' commit_msg.txt > commit_body.txt
32
33       - name: Check signed-off
34         run: |
35           # Check string starting from "Signed-off-by:"
36           count=$(cat commit_body.txt | grep 'Signed-off-by:' | wc -l)
37           if [[ ! "$count" -ge "1" ]]; then
38             exit 1
39           fi
40
41           echo "Signed-off-by is OK"
42
43       - name: Check body words
44         # Run if check_signed_off step is failed
45         if: ${{ always() }}
46         run: |
47           count=$(cat commit_body.txt | sed '/Signed-off-by:/d' | wc -w)
48           echo "Commit body word check: $count words"
49           if [[ "$count" -lt "5" ]]; then
50             exit 1
51           fi