CI: Update main.yml #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Commit Message Prefix Check | |
on: [push] | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Get Commit Message | |
run: | | |
commit_message=$(git log --format=%B -n 1 ${{ github.event.before }}) | |
valid_prefixes=("feat!" "feat" "fix" "patch" "chore" "build" "debug" "refactor" "revert" "ci" "perf" "style" "test" "docs" "wip") | |
valid_commit=0 | |
for prefix in "${valid_prefixes[@]}"; do | |
if [[ $commit_message == "$prefix"* ]]; then | |
valid_commit=1 | |
break | |
fi | |
done | |
if [ $valid_commit -eq 1 ]; then | |
echo "Commit message includes a valid prefix. Build passed." | |
echo $commit_message | |
else | |
echo "Commit message does not include a valid prefix. Build failed." | |
echo $commit_message | |
exit 1 | |
fi |