From a1c6d7f333942f15221b75a588292aae420872d8 Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Thu, 26 Sep 2024 09:10:59 +0100 Subject: [PATCH] ci_: validate pr title (#5872) --- .github/workflows/commit-check.yml | 6 +++--- .github/workflows/pr-lint.yml | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/pr-lint.yml diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index 01d359b7085..a66fcccb0e0 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -9,8 +9,8 @@ on: - labeled - unlabeled jobs: - main: - name: Validate format + lint_pr_commits: + name: Validate commit messages runs-on: ubuntu-latest permissions: pull-requests: write @@ -23,6 +23,7 @@ jobs: - name: Check commit message id: check_commit_message + if: always() run: | set +e @@ -50,7 +51,6 @@ jobs: echo "error_message<<$EOF" >> "$GITHUB_ENV" echo "${invalid_commit_messages}" >> "$GITHUB_ENV" echo "$EOF" >> "$GITHUB_ENV" - fi - name: "Publish failed commit messages" diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/pr-lint.yml new file mode 100644 index 00000000000..94ea81585a1 --- /dev/null +++ b/.github/workflows/pr-lint.yml @@ -0,0 +1,21 @@ +name: "Conventional Commits" + +on: + pull_request: + types: + - opened + - edited + - reopened + - synchronize +jobs: + lint_pr_title: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # Keep regex in sync with ./_assets/scripts/parse_commits.sh#L25 + headerPattern: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(.*\))?(\_|!): (.*)$' + headerPatternCorrespondence: type, scope, breaking, subject