From b6515bcf545b018e746d769d85e854ad87849588 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 6 Jun 2024 09:48:00 +0200 Subject: [PATCH] add conventional commit auto labeler --- .github/release-drafter.yml | 50 -------------------------------- .github/release.yml | 36 +++++++++++++++++++++++ .github/workflows/chore.yml | 58 +++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 50 deletions(-) create mode 100644 .github/release.yml create mode 100644 .github/workflows/chore.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index af87647..58eacf0 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -38,53 +38,3 @@ autolabeler: - label: breaking title: - '/^[a-z]+(\(.*\))?\!\:/' -# ------------------------------------ RELEASE CONFIGURATION ------------------------------------ # -category-template: "### $TITLE" -change-template: "- $TITLE by @$AUTHOR in [#$NUMBER]($URL)" -replacers: - # remove conventional commit tag & scope from change list - - search: '/- [a-z]+(\(.*\))?(\!)?\: /g' - replace: "- " -template: | - ## What's Changed - - $CHANGES - - **Full Changelog:** [`$PREVIOUS_TAG...v$RESOLVED_VERSION`](https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) -categories: - - title: โš ๏ธ Breaking Changes - labels: - - breaking - - title: โœจ New Features - labels: - - enhancement - - title: ๐Ÿž Bug Fixes - labels: - - fix - - title: ๐ŸŽ๏ธ Performance Improvements - labels: - - performance - - title: ๐Ÿ“š Documentation - labels: - - documentation - - title: ๐Ÿ—๏ธ Testing - labels: - - test - - title: โš™๏ธ Automation - labels: - - ci - - title: ๐Ÿ›  Builds - labels: - - build - - title: ๐Ÿ’Ž Code Style - labels: - - style - - title: ๐Ÿ“ฆ Refactorings - labels: - - refactor - - title: โ™ป๏ธ Chores - labels: - - chore - - title: ๐Ÿ—‘ Reverts - labels: - - revert diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..f9c1495 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,36 @@ +changelog: + exclude: + labels: + - ignore for release + categories: + - title: ๐Ÿšจ Breaking changes + labels: + - breaking + - title: โœจ New features + labels: + - enhancement + - title: ๐Ÿš€ Performance + labels: + - performance + - title: ๐Ÿ› Bug fixes + labels: + - bug + - fix + - title: ๐Ÿ“ Documentation + labels: + - documentation + - title: ๐Ÿงช Tests + labels: + - test + - title: โฌ†๏ธ Dependencies + labels: + - dependencies + - title: ๐Ÿค– CI + labels: + - ci + - title: ๐Ÿ—๏ธ Refactor + labels: + - refactor + - title: ๐Ÿคท๐Ÿป Other changes + labels: + - '*' diff --git a/.github/workflows/chore.yml b/.github/workflows/chore.yml new file mode 100644 index 0000000..e610c0f --- /dev/null +++ b/.github/workflows/chore.yml @@ -0,0 +1,58 @@ +name: Chore +on: + pull_request: + branches: [main] + types: [opened, reopened, edited, synchronize] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-pr-title: + name: Check PR Title + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - name: Check valid conventional commit message + id: lint + uses: amannn/action-semantic-pull-request@cfb60706e18bc85e8aec535e3c577abe8f70378e + with: + subjectPattern: ^[A-Za-z].+[^. ]$ # subject must start with letter and may not end with a dot/space + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Post comment about invalid PR title + if: failure() + uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 + with: + header: conventional-commit-pr-title + message: | + Thank you for opening this pull request! ๐Ÿ‘‹๐Ÿผ + + This repository requires pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted. + +
Details + + ``` + ${{ steps.lint.outputs.error_message }} + ``` + +
+ + - name: Delete comment about invalid PR title + if: success() + uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 + with: + header: conventional-commit-pr-title + delete: true + + - name: Assign labels + uses: release-drafter/release-drafter@3f0f87098bd6b5c5b9a36d49c41d998ea58f9348 + with: + disable-releaser: true + disable-autolabeler: false + env: + GITHUB_TOKEN: ${{ github.token }}