Skip to content

Instantly share code, notes, and snippets.

@paprikka
Created November 19, 2024 15:47
Show Gist options
  • Save paprikka/41435ef90c314b295a3009609fbb5337 to your computer and use it in GitHub Desktop.
Save paprikka/41435ef90c314b295a3009609fbb5337 to your computer and use it in GitHub Desktop.
name: Prevent Merge if [no ci] is in Commits
on:
pull_request:
types: [opened, synchronize]
jobs:
check-commits:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Validate Commit Messages
run: |
# Fetch all commits in the pull request
git fetch origin ${{ github.event.pull_request.base.ref }} \
${{ github.event.pull_request.head.ref }}
# Check for [no ci] in commit messages
if git log --pretty=format:%s origin/${{ github.event.pull_request.base.ref }}..HEAD | grep -iq "\[no ci\]"; then
echo "Error: '[no ci]' found in commit messages.";
exit 1;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment