From f2d949b64e991f7702abd56774035149b588c55d Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Thu, 4 Jul 2024 12:11:37 -0300 Subject: [PATCH] feat(PR): add conditions to label pr (#2532) * chore: update conventional-labeler action to version 2.0.0 * chore: add 'bug' label to fix category in release.yml * chore(conventional-labels.yml): add 'Validate PR' job to validate pull requests before labeling them chore(conventional-labels.yml): add 'Label PR' job to label pull requests after validation is successful * chore(conventional-labels.yml): update conditional statement in Label PR job to exclude Bot users from linting and only run if PR validation is successful * chore(conventional-labels.yml): update type_labels mapping to align with conventional commit keywords for better labeling in GitHub actions. * fix(conventional-labels.yml): run workflow only on editing the PR * chore(conventional-labels.yml): do not require an issue reference --- .github/release.yml | 1 + .github/workflows/conventional-labels.yml | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/release.yml b/.github/release.yml index 9b53122d8..fd78aad92 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -12,6 +12,7 @@ changelog: description: Bug fixes and patches labels: - fix + - bug - title: 📝 Documentation Updates description: Changes to documentation labels: diff --git a/.github/workflows/conventional-labels.yml b/.github/workflows/conventional-labels.yml index 7bb581296..0f89f9723 100644 --- a/.github/workflows/conventional-labels.yml +++ b/.github/workflows/conventional-labels.yml @@ -3,22 +3,29 @@ name: Label PRs with Conventional Commits on: pull_request_target: - types: [ opened, edited , synchronize] + types: [ opened, edited , reopened] jobs: validate-pr: + name: Validate PR runs-on: ubuntu-latest + outputs: + validate_output: ${{ steps.validate.outputs }} steps: - name: Validate the pull request + id: validate uses: Namchee/conventional-pr@v0.15.4 with: access_token: ${{ secrets.GITHUB_TOKEN }} verbose: true + issue: false + label: + needs: validate-pr + name: Label PR runs-on: ubuntu-latest - name: Lint PR + if: ${{ github.event.pull_request.user.type != 'Bot' && needs.validate-pr.outputs.validate_output == 'true' }} steps: - - name: label - uses: action-runner/conventional-labeler@v1 + - uses: bcoe/conventional-release-labels@v1 with: - access_token: ${{ secrets.GITHUB_TOKEN }} + type_labels: '{"feat": "enhancement","fix": "bug","docs": "documentation","style": "style","refactor": "refactor","perf": "performance","test": "test","chore": "chore","build": "build"}'