diff --git a/.github/labeler.yml b/.github/labeler.yml index 4c01fa00b..3114d0ef4 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -10,19 +10,19 @@ # Add 'enhancement' label to any PR where the head branch name contains `feat` enhancement: - - head-branch: ['feat'] + - head-branch: [feat, Feat, FEAT] # Add 'repo' label to any PR where the head branch name contains `repo` # or files in the .github dir repo: - any: - - head-branch: ['repo'] + - head-branch: [repo, Repo] - changed-files: - - any-glob-to-any-file: '.github' + - any-glob-to-any-file: .github # Add 'bug' label to any PR where the head branch name contains `fix` or `bug` bugfix: - - head-branch: ['fix', 'bug'] + - head-branch: [fix, bug, Fix, FIX, Bug, BUG] # our fallback - bug except repo, feat, or automated pipelines # bug_fallthrough: diff --git a/.github/workflows/pr_enforce_labels.yml b/.github/workflows/pr_enforce_labels.yml new file mode 100644 index 000000000..5ef8023b0 --- /dev/null +++ b/.github/workflows/pr_enforce_labels.yml @@ -0,0 +1,25 @@ +name: Check PR Labels + +on: + pull_request: + types: [edited, labeled] + +permissions: + pull-requests: read + contents: read + +jobs: + check-label: + runs-on: ubuntu-latest + steps: + - name: Check for PR labels + uses: actions/github-script@v7 + with: + script: | + const labels = context.payload.pull_request.labels.map(label => label.name); + const requiredLabels = ['bugfix', 'enhancement', 'automation', 'dependencies', 'repo', 'release']; + const hasRequiredLabel = labels.some(label => requiredLabels.includes(label)); + console.log(labels); + if (!hasRequiredLabel) { + core.setFailed(`PR must have at least one of the following labels before it can be merged: ${requiredLabels.join(', ')}.`); + } \ No newline at end of file diff --git a/.github/workflows/pull-request-target.yml b/.github/workflows/pull-request-target.yml new file mode 100644 index 000000000..cf0325677 --- /dev/null +++ b/.github/workflows/pull-request-target.yml @@ -0,0 +1,15 @@ +name: "Pull Request Labeler" +on: +- pull_request_target +# Do not execute arbitary code on this workflow. +# See warnings at https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#pull_request_target + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - id: label-the-PR + uses: actions/labeler@v5 \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 81e2835be..2de575144 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -56,34 +56,3 @@ jobs: } exit_on_result "build_and_detekt" "${{ needs.build_and_detekt.result }}" exit_on_result "androidTest" "${{ needs.androidTest.result }}" - - labeler: - permissions: - contents: read - pull-requests: write - runs-on: ubuntu-latest - steps: - - id: label-the-PR - uses: actions/labeler@v5 - continue-on-error: true - - check-label: - runs-on: ubuntu-latest - needs: - [ - check-workflow-status, - labeler - ] - if: always() - steps: - - name: Check for PR labels - uses: actions/github-script@v7 - with: - script: | - const labels = context.payload.pull_request.labels.map(label => label.name); - const requiredLabels = ['bugfix', 'enhancement', 'automation', 'dependencies', 'repo', 'release']; - const hasRequiredLabel = labels.some(label => requiredLabels.includes(label)); - console.log(labels); - if (!hasRequiredLabel) { - core.setFailed(`PR must have at least one of the following labels before it can be merged: ${requiredLabels.join(', ')}.`); - }