From 4d6f6a7b335e2de92befa14f8bcbbb67f197a1e1 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Fri, 13 Sep 2024 10:45:00 -0700 Subject: [PATCH 1/5] refactor: pr labeller actions --- .github/workflows/gh-pr-label-paths.yml | 22 +++++++++++ .github/workflows/gh-pr-label-title.yml | 51 +++++++++++++++++++++++++ .github/workflows/gh-pr-labeler.yml | 44 --------------------- 3 files changed, 73 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/gh-pr-label-paths.yml create mode 100644 .github/workflows/gh-pr-label-title.yml delete mode 100644 .github/workflows/gh-pr-labeler.yml diff --git a/.github/workflows/gh-pr-label-paths.yml b/.github/workflows/gh-pr-label-paths.yml new file mode 100644 index 0000000000..89aef59c2f --- /dev/null +++ b/.github/workflows/gh-pr-label-paths.yml @@ -0,0 +1,22 @@ +# Automatically apply labels to PR based on filepaths of modified files +name: Github PR Label Paths +on: + pull_request: +jobs: + label: + if: ${{ !contains(github.event.pull_request.labels.*.name , 'no-autolabel')}} + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + # Checkout repo to access local templates (if updated) + - name: checkout + uses: actions/checkout@main + # Assign labels based on files modified + # https://github.com/actions/labeler + - name: Assign PR path Labels + uses: actions/labeler@v5 + with: + configuration-path: .github/pr-labeler.config.yml + sync-labels: false diff --git a/.github/workflows/gh-pr-label-title.yml b/.github/workflows/gh-pr-label-title.yml new file mode 100644 index 0000000000..5e60e63f21 --- /dev/null +++ b/.github/workflows/gh-pr-label-title.yml @@ -0,0 +1,51 @@ +# Automatically apply labels to PR based on title (if written in semantic format) +name: Github PR Label Title +on: + pull_request: + # https://frontside.com/blog/2020-05-26-github-actions-pull_request/ + types: + - opened + - edited +jobs: + label: + # Avoid re-label if title not changed or using custom label to prevent + # https://github.com/orgs/community/discussions/101695 + if: | + ${{ !contains(github.event.pull_request.labels.*.name , 'no-autolabel')}} && + (event.type == 'opened' || event.changes.title.from) + runs-on: ubuntu-latest + steps: + # Checkout repo to access local templates (if updated) + - name: checkout + uses: actions/checkout@main + # Check if PR title matches conventional commit standard + # Not strictly enforced so allow continue on error + # https://github.com/marketplace/actions/semantic-pull-request + - name: Validate PR title + uses: amannn/action-semantic-pull-request@v5 + continue-on-error: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Assign labels based on conventional PR title + # https://github.com/marketplace/actions/conventional-release-labels + - name: Assign PR Name Labels + uses: bcoe/conventional-release-labels@v1.3.1 + with: + # Labels assigned based on pr name prefix + type_labels: | + { + "breaking": "breaking", + "chore": "maintenance", + "docs": "documentation", + "feat": "feature", + "fix": "fix", + "refactor": "maintenance", + "Breaking": "breaking", + "Chore": "maintenance", + "Docs": "documentation", + "Feat": "feature", + "Fix": "fix", + "Refactor": "maintenance" + } + # Do not ignore any labels (default ignores chore:) + ignored_types: '[]' diff --git a/.github/workflows/gh-pr-labeler.yml b/.github/workflows/gh-pr-labeler.yml deleted file mode 100644 index 6ecd6b7ecc..0000000000 --- a/.github/workflows/gh-pr-labeler.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Github PR Labeler -on: - # TODO - replace with pull_request_target when working in master - pull_request: - types: - - opened - - edited - - synchronize -jobs: - label: - runs-on: ubuntu-latest - steps: - # Check if PR title matches conventional commit standard - # Not strictly enforced so allow continue on error - # https://github.com/marketplace/actions/semantic-pull-request - - name: Validate PR title - uses: amannn/action-semantic-pull-request@v5 - continue-on-error: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Assign labels based on conventional PR title - # https://github.com/marketplace/actions/conventional-release-labels - - name: Assign PR Name Labels - uses: bcoe/conventional-release-labels@v1.3.1 - with: - # Labels assigned based on pr name prefix - type_labels: | - { - "breaking": "breaking", - "chore": "maintenance", - "docs": "documentation", - "feat": "feature", - "fix": "fix", - "refactor": "maintenance" - } - # Do not ignore any labels (default ignores chore:) - ignored_types: '[]' - # Assign labels based on files modified - - name: Assign PR path Labels - uses: actions/labeler@v4 - with: - configuration-path: .github/pr-labeler.config.yml - - \ No newline at end of file From faab8a320af225160d8f2d215ad57fd7fd394428 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Fri, 13 Sep 2024 11:03:20 -0700 Subject: [PATCH 2/5] chore: update labeller config --- .github/pr-labeler.config.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/pr-labeler.config.yml b/.github/pr-labeler.config.yml index 98b7d9b45f..5396f0eb51 100644 --- a/.github/pr-labeler.config.yml +++ b/.github/pr-labeler.config.yml @@ -1,3 +1,12 @@ -# Additional labels to assign based on file changes -"documentation": - - documentation/**/* +# Patterns to match to auto-assign labels based on path changes +# https://github.com/actions/labeler/tree/v5/?tab=readme-ov-file#match-object + +# Documentation +'documentation': + - changed-files: + - any-glob-to-any-file: 'documentation/**/*' + +# Scripts +'scripts': + - changed-files: + - any-glob-to-any-file: 'packages/scripts/**/*' \ No newline at end of file From 48c93e62ae281fa02d846b2477cf4df130483e86 Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Fri, 13 Sep 2024 11:22:24 -0700 Subject: [PATCH 3/5] chore: update pr label title trigger --- .github/workflows/gh-pr-label-title.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pr-label-title.yml b/.github/workflows/gh-pr-label-title.yml index 5e60e63f21..8dee66e103 100644 --- a/.github/workflows/gh-pr-label-title.yml +++ b/.github/workflows/gh-pr-label-title.yml @@ -5,7 +5,7 @@ on: # https://frontside.com/blog/2020-05-26-github-actions-pull_request/ types: - opened - - edited + - ready_for_review jobs: label: # Avoid re-label if title not changed or using custom label to prevent From e7ab562b951928b9707540507552b69e19da867d Mon Sep 17 00:00:00 2001 From: chrismclarke Date: Fri, 13 Sep 2024 11:27:44 -0700 Subject: [PATCH 4/5] chore: update pr path label triggers --- .github/workflows/gh-pr-label-paths.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/gh-pr-label-paths.yml b/.github/workflows/gh-pr-label-paths.yml index 89aef59c2f..55f6f46c13 100644 --- a/.github/workflows/gh-pr-label-paths.yml +++ b/.github/workflows/gh-pr-label-paths.yml @@ -2,6 +2,10 @@ name: Github PR Label Paths on: pull_request: + # https://frontside.com/blog/2020-05-26-github-actions-pull_request/ + types: + - opened + - synchronize jobs: label: if: ${{ !contains(github.event.pull_request.labels.*.name , 'no-autolabel')}} From 7200103966258e0d62aaa852b23a865fb6a537fe Mon Sep 17 00:00:00 2001 From: Johnny McQuade Date: Tue, 17 Sep 2024 13:33:00 +0100 Subject: [PATCH 5/5] empty commit to test gh action trigger