2023-12-19 13:37:16 -05:00
|
|
|
---
|
|
|
|
name: Lint commit
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
pull_request:
|
|
|
|
merge_group:
|
|
|
|
|
2023-12-22 07:22:15 -05:00
|
|
|
# Don't grant any access by default
|
|
|
|
permissions: {}
|
|
|
|
|
2023-12-19 13:37:16 -05:00
|
|
|
jobs:
|
|
|
|
commitlint:
|
|
|
|
runs-on: ubuntu-latest
|
2023-12-22 07:22:15 -05:00
|
|
|
permissions:
|
2024-08-15 04:21:26 -04:00
|
|
|
contents: read
|
2023-12-19 13:37:16 -05:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Check if the pull request contains a single commit
|
|
|
|
if: github.event_name == 'pull_request'
|
|
|
|
run: |
|
|
|
|
commit_count=${{ github.event.pull_request.commits }}
|
|
|
|
|
|
|
|
if [ -z ${commit_count} ]; then
|
|
|
|
echo "[ERROR] commit_count is empty"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${commit_count} -ne 1 ]]; then
|
|
|
|
echo "[ERROR] This pull request contains ${commit_count} commits. Squash these commits into a single commit."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "This pull request contains ${commit_count} commit."
|
|
|
|
fi
|