diff options
Diffstat (limited to '.github/workflows/labeler.yml')
-rw-r--r-- | .github/workflows/labeler.yml | 86 |
1 files changed, 81 insertions, 5 deletions
diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 76fc8793fa..a2e0566eb1 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -1,8 +1,9 @@ name: "Pull Request Labeler" on: pull_request_target: - types: opened + types: [opened] jobs: + triage: runs-on: ubuntu-latest permissions: @@ -12,8 +13,10 @@ jobs: - uses: actions/labeler@main with: repo-token: "${{ secrets.GITHUB_TOKEN }}" + type-scope: runs-on: ubuntu-latest + needs: ["triage"] permissions: contents: write pull-requests: write @@ -23,8 +26,81 @@ jobs: PR_NUMBER: ${{ github.event.pull_request.number }} PR_TITLE: ${{ github.event.pull_request.title }} steps: - # Extract type and try to add it as a label - - run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|([[:alpha:]]+)(\(.*\))?!?:.*|\1|')" || true + - name: "Extract commit type and add as label" + continue-on-error: true + run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|([[:alpha:]]+)(\(.*\))?!?:.*|\1|')" + - name: "Extract commit scope and add as label" + continue-on-error: true + run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')" + + add-reviewer: + # This job currently doesn't work due to a bug in GitHub CLI. + # + # Issue: https://github.com/cli/cli/issues/4844 + # PR that will fix it: https://github.com/cli/cli/pull/4876 + # + # The current workaround is to temporarily add "continue-on-error" flag so + # the whole workflow doesn't get flagged as a failure. + runs-on: ubuntu-latest + needs: ["triage", "type-scope"] + permissions: + contents: write + pull-requests: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + PR_NUMBER: ${{ github.event.pull_request.number }} + continue-on-error: true + steps: + - name: Get labels + id: labels + run: echo "::set-output name=labels::$(gh pr view $PR_NUMBER --json labels --jq '.labels.[].name' | tr '\n' '%')" + + # The % at the end of the label is a hack to avoid selecting a label that + # is substring of another label. So if there is a label "cinema" then we + # don't accidentally want to interpret that as the label "ci" + + - if: contains(steps.labels.outputs.labels, 'api%') + run: gh pr edit $PR_NUMBER --add-reviewer bfredl,gpanders,muniter + + - if: contains(steps.labels.outputs.labels, 'ci%') + run: gh pr edit $PR_NUMBER --add-reviewer jamessan + + - if: contains(steps.labels.outputs.labels, 'diagnostic%') + run: gh pr edit $PR_NUMBER --add-reviewer gpanders + + - if: contains(steps.labels.outputs.labels, 'distribution%') + run: gh pr edit $PR_NUMBER --add-reviewer jamessan + + - if: contains(steps.labels.outputs.labels, 'documentation%') + run: gh pr edit $PR_NUMBER --add-reviewer clason + + - if: contains(steps.labels.outputs.labels, 'extmarks%') + run: gh pr edit $PR_NUMBER --add-reviewer bfredl + + - if: contains(steps.labels.outputs.labels, 'filetype%') + run: gh pr edit $PR_NUMBER --add-reviewer clason,gpanders + + - if: contains(steps.labels.outputs.labels, 'gui%') + run: gh pr edit $PR_NUMBER --add-reviewer glacambre,smolck + + - if: contains(steps.labels.outputs.labels, 'platform:windows%') + run: gh pr edit $PR_NUMBER --add-reviewer erw7 + + - if: contains(steps.labels.outputs.labels, 'lsp%') + run: gh pr edit $PR_NUMBER --add-reviewer mfussenegger,mjlbach + + - if: contains(steps.labels.outputs.labels, 'terminal%') + run: gh pr edit $PR_NUMBER --add-reviewer erw7 + + - if: contains(steps.labels.outputs.labels, 'treesitter%') + run: gh pr edit $PR_NUMBER --add-reviewer bfredl,vigoux + + - if: contains(steps.labels.outputs.labels, 'typo%') + run: gh pr edit $PR_NUMBER --add-reviewer dundargoc + + - if: contains(steps.labels.outputs.labels, 'ui%') + run: gh pr edit $PR_NUMBER --add-reviewer bfredl - # Extract scope and try to add it as a label - - run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')" || true + - if: contains(steps.labels.outputs.labels, 'vim-patch%') + run: gh pr edit $PR_NUMBER --add-reviewer janlazo,seandewar |