neovim/.github/workflows/labeler.yml
zeertzjq 8afdc1f386
ci(labeler): run "type-scope" after "triage"
Problem:    When "triage" job is run after "type-scope" job, it may
            remove labels added by the "type-scope" job.
Solution:   Run "type-scope" job after "triage" job.
2023-08-09 09:27:51 +08:00

40 lines
1.3 KiB
YAML

name: "Pull Request Labeler"
on:
pull_request_target:
types: [opened]
jobs:
triage:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/labeler@v4
with:
sync-labels: ""
type-scope:
needs: triage
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- name: "Extract commit type and add as label"
run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|([[:alpha:]]+)(\(.*\))?!?:.*|\1|')" || true
- name: "Extract commit scope and add as label"
run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')" || true
- name: "Extract if the PR is a breaking change and add it as label"
run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+(\(.*\))?!:.*|breaking-change|')" || true
request-reviewer:
needs: ["triage", "type-scope"]
permissions:
pull-requests: write
uses: ./.github/workflows/add-reviewers.yml