Created
May 31, 2022 07:18
-
-
Save matthiasbeyer/0cea6298547f4f629f9cb624c639e6eb to your computer and use it in GitHub Desktop.
github action for linting commit messages with gitlint
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: lint commit messages | |
on: | |
pull_request: | |
jobs: | |
commit-lint: | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.even.pull_request.head.sha }} # Checkout pull request HEAD commit instead of merge commit | |
fetch-depth: 0 # fetch complete history | |
- uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10' | |
- name: Install gitlint | |
run: pip install gitlint | |
- name: Run gitlint | |
run: | | |
if [[ -z "${GITHUB_BASE_REF}" ]]; then | |
BASE=origin/master | |
else | |
BASE="${GITHUB_BASE_REF}" | |
fi | |
echo "Linting: ${BASE}..HEAD" | |
gitlint --commits ${BASE}..HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment