From ca40667068a0266ad2943304fb0d0c2620e8ab73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=8F=E4=BA=AC=E5=8D=8E?= <130035064+ZhuJHua@users.noreply.github.com> Date: Sun, 19 Jan 2025 01:02:07 +0800 Subject: [PATCH] Merge pull request #110 * ci(*): optimize release note generation logic --- .github/release-drafter.yml | 33 +++++++++++++++------ .github/workflows/label-pr.yml | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/label-pr.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 3b813cb..da558bf 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -11,22 +11,37 @@ categories: - title: ๐Ÿ› ๏ธ Chores labels: - chore - - title: ๐Ÿ—๏ธ Build System + - title: ๐Ÿ“š Documentation Updates labels: - - build - - title: โšก Performance Improvements - labels: - - perf - - title: ๐Ÿ”จ Refactors - labels: - - refactor + - docs - title: ๐ŸŽจ Code Style Updates labels: - style + - title: ๐Ÿ”จ Refactors + labels: + - refactor + - title: โšก Performance Improvements + labels: + - perf + - title: โœ… Tests + labels: + - test + - title: ๐Ÿ—๏ธ Build System + labels: + - build + - title: ๐Ÿงน CI/CD Changes + labels: + - ci + - title: โช Reverts + labels: + - revert + - title: โ“ What is This + labels: + - '?' change-template: '- $TITLE (#$NUMBER) by @$AUTHOR' template: | - ## ๐Ÿ”ฅ What's Changed + # ๐Ÿ”ฅ What's Changed $CHANGES diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml new file mode 100644 index 0000000..4be5b14 --- /dev/null +++ b/.github/workflows/label-pr.yml @@ -0,0 +1,54 @@ +name: Label PR Based on Conventional Commits + +on: + pull_request: + types: [ opened, synchronize, reopened ] + +jobs: + label-pr: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Analyze PR Title + id: analyze_title + run: | + pr_title="${{ github.event.pull_request.title }}" + label="" + + # Match against Conventional Commits + if [[ "$pr_title" == feat* ]]; then + label="feat" + elif [[ "$pr_title" == fix* ]]; then + label="fix" + elif [[ "$pr_title" == chore* ]]; then + label="chore" + elif [[ "$pr_title" == docs* ]]; then + label="docs" + elif [[ "$pr_title" == style* ]]; then + label="style" + elif [[ "$pr_title" == refactor* ]]; then + label="refactor" + elif [[ "$pr_title" == perf* ]]; then + label="perf" + elif [[ "$pr_title" == test* ]]; then + label="test" + elif [[ "$pr_title" == build* ]]; then + label="build" + elif [[ "$pr_title" == ci* ]]; then + label="ci" + elif [[ "$pr_title" == revert* ]]; then + label="revert" + else + label="?" + fi + + echo "label=$label" >> $GITHUB_ENV + + - name: Add Label to PR + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: ${{ env.label }} + github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file