penpot/.github/workflows/commit-checker.yml
penpot-renovate[bot] 53f83c98cf
⬆️ Update GitHub Actions (#12401)
- actions/checkout v7 (.github/workflows/commit-checker.yml)
- actions/download-artifact v8.0.2 (.github/workflows/tests-e2e.yml)
- actions/upload-artifact v7.0.2 (.github/workflows/tests-e2e.yml)
- actions/upload-artifact v7.0.2 (.github/workflows/tests-e2e.yml)
- actions/upload-artifact v7.0.2 (.github/workflows/tests-e2e.yml)
- actions/upload-artifact v7.0.2 (.github/workflows/tests-e2e.yml)

Signed-off-by: penpot-renovate[bot] <338182062+penpot-renovate[bot]@users.noreply.github.com>
Co-authored-by: penpot-renovate[bot] <338182062+penpot-renovate[bot]@users.noreply.github.com>
2026-10-17 14:01:55 +02:00

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"