mirror of
https://github.com/penpot/penpot.git
synced 2026-10-29 22:10:34 +00:00
92 lines
3.6 KiB
YAML
92 lines
3.6 KiB
YAML
name: 'Commit Message Check'
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- edited
|
|
- reopened
|
|
- synchronize
|
|
- ready_for_review
|
|
push:
|
|
branches:
|
|
- main
|
|
- develop
|
|
- staging
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: read
|
|
|
|
jobs:
|
|
check-commit-message:
|
|
if: ${{ !github.event.pull_request.draft }}
|
|
name: Check Commit Message
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check Commit Type
|
|
uses: gsactions/commit-message-checker@16fa2d5de096ae0d35626443bcd24f1e756cafee # v2.0.0
|
|
with:
|
|
pattern: '^(((:(lipstick|globe_with_meridians|wrench|books|arrow_up|arrow_down|zap|ambulance|construction|boom|fire|whale|bug|sparkles|paperclip|tada|recycle|rewind|construction_worker):)\s[A-Z].*[^.])|(Merge|Revert|Reapply).+[^.])$'
|
|
flags: 'gm'
|
|
error: 'Commit should match CONTRIBUTING.md guideline'
|
|
checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
|
|
accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true
|
|
|
|
# - name: Check Line Length
|
|
# uses: gsactions/commit-message-checker@v2
|
|
# with:
|
|
# pattern: '^[^#].{74}'
|
|
# error: 'The maximum line length of 74 characters is exceeded.'
|
|
# excludeDescription: 'true' # optional: this excludes the description body of a pull request
|
|
# excludeTitle: 'true' # optional: this excludes the title of a pull request
|
|
# checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request
|
|
# accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is ue
|
|
# - name: Check for Resolves / Fixes
|
|
# uses: gsactions/commit-message-checker@v2
|
|
# with:
|
|
# pattern: '^.+(Resolves|Fixes): \#[0-9]+$'
|
|
# error: 'You need at least one "Resolves|Fixes: #<issue number>" line.'
|
|
|
|
check-commit-guidelines:
|
|
if: ${{ !github.event.pull_request.draft }}
|
|
name: Check Commit Guidelines
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# On PR events check out the base ref, so the script below is
|
|
# always the trusted version: PR commits are only read, never
|
|
# executed. On push events this resolves to the pushed sha.
|
|
- name: Checkout trusted code
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ github.event.pull_request.base.sha || github.sha }}
|
|
|
|
- name: Fetch PR commits
|
|
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }}
|
|
run: git fetch --no-tags origin "pull/${{ github.event.pull_request.number }}/head:pr-head"
|
|
|
|
- name: Run scripts/check-commit on every new commit
|
|
run: |
|
|
set -euo pipefail
|
|
if [ "${{ github.event_name }}" = "push" ]; then
|
|
if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
|
|
RANGE="${{ github.sha }}"
|
|
else
|
|
RANGE="${{ github.event.before }}..${{ github.sha }}"
|
|
fi
|
|
else
|
|
RANGE="${{ github.event.pull_request.base.sha }}..pr-head"
|
|
fi
|
|
COMMITS="$(git rev-list --reverse "$RANGE")"
|
|
if [ -z "$COMMITS" ]; then
|
|
echo "No new commits to check."
|
|
exit 0
|
|
fi
|
|
FAILED=0
|
|
for COMMIT in $COMMITS; do
|
|
./scripts/check-commit -c "$COMMIT" || FAILED=1
|
|
done
|
|
exit "$FAILED"
|
|
|
|
|