|
| 1 | +# ******************************************************************************* |
| 2 | +# Copyright (c) 2024 Contributors to the Eclipse Foundation |
| 3 | +# |
| 4 | +# See the NOTICE file(s) distributed with this work for additional |
| 5 | +# information regarding copyright ownership. |
| 6 | +# |
| 7 | +# This program and the accompanying materials are made available under the |
| 8 | +# terms of the Apache License Version 2.0 which is available at |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# SPDX-License-Identifier: Apache-2.0 |
| 12 | +# ******************************************************************************* |
| 13 | + |
| 14 | +name: "Gitlint Action" |
| 15 | +description: "An action to install and run Gitlint on PR commits" |
| 16 | +inputs: |
| 17 | + pr-number: |
| 18 | + description: "Pull Request number used to fetch commits" |
| 19 | + required: true |
| 20 | + base-branch: |
| 21 | + description: "Base branch to compare commits against (default: origin/main)" |
| 22 | + default: "origin/main" |
| 23 | + required: false |
| 24 | +runs: |
| 25 | + using: "docker" |
| 26 | + image: "jorisroovers/gitlint:0.19.1" |
| 27 | + entrypoint: /bin/sh |
| 28 | + args: |
| 29 | + - -c |
| 30 | + - | |
| 31 | + git config --global --add safe.directory /github/workspace && \ |
| 32 | + git fetch origin +refs/heads/main:refs/remotes/origin/main && \ |
| 33 | + git fetch origin +refs/pull/${{ inputs.pr-number }}/head && \ |
| 34 | + if ! gitlint --commits ${{ inputs.base-branch }}..HEAD; then \ |
| 35 | + echo -e "\nWARNING: Your commit message does not follow the required format." && \ |
| 36 | + echo "Formatting rules: https://eclipse-score.github.io/score/process/guidance/git/index.html" && \ |
| 37 | + echo -e "To fix your commit message, run:\n" && \ |
| 38 | + echo " git commit --amend" && \ |
| 39 | + echo "Then update your commit (fix gitlint warnings). Finally, force-push:" && \ |
| 40 | + echo " git push --force-with-lease" && \ |
| 41 | + exit 1; \ |
| 42 | + fi |
0 commit comments