name: PR Labeler on: pull_request: types: [opened, edited, synchronize] permissions: contents: read pull-requests: write jobs: label: name: Label PR runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Label based on files changed uses: actions/labeler@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} configuration-path: .github/labeler.yml - name: Label based on PR size uses: codelytv/pr-size-labeler@v1 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} xs_label: 'size/xs' xs_max_size: 10 s_label: 'size/s' s_max_size: 100 m_label: 'size/m' m_max_size: 500 l_label: 'size/l' l_max_size: 1000 xl_label: 'size/xl' fail_if_xl: false - name: Label based on title uses: actions/github-script@v7 with: script: | const title = context.payload.pull_request.title.toLowerCase(); const labels = []; if (title.includes('fix') || title.includes('bug')) labels.push('bug'); if (title.includes('feat') || title.includes('feature')) labels.push('enhancement'); if (title.includes('docs') || title.includes('documentation')) labels.push('documentation'); if (title.includes('refactor')) labels.push('refactor'); if (title.includes('test')) labels.push('testing'); if (title.includes('ci') || title.includes('workflow')) labels.push('ci/cd'); if (title.includes('security')) labels.push('security'); if (title.includes('breaking')) labels.push('breaking-change'); if (title.includes('wip') || title.includes('draft')) labels.push('work-in-progress'); if (labels.length > 0) { await github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.payload.pull_request.number, labels: labels }); }