Skip to content

Instantly share code, notes, and snippets.

@matthiasbeyer
Created May 31, 2022 07:18
Show Gist options
  • Save matthiasbeyer/0cea6298547f4f629f9cb624c639e6eb to your computer and use it in GitHub Desktop.
Save matthiasbeyer/0cea6298547f4f629f9cb624c639e6eb to your computer and use it in GitHub Desktop.
github action for linting commit messages with gitlint
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