|
| 1 | + |
| 2 | +name: Set default values to PR |
| 3 | +# Add the PR to the central project (status in project is set via workflow in project) |
| 4 | +# Add the creator of the PR as assignee |
| 5 | +# Add the next available milestone to the PR |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + types: |
| 10 | + - opened |
| 11 | + |
| 12 | +permissions: |
| 13 | + issues: write |
| 14 | + pull-requests: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + set-default-values: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Add creator as assignee |
| 21 | + if: ${{ github.actor != 'dependabot[bot]' }} |
| 22 | + env: |
| 23 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + run: | |
| 25 | + gh api \ |
| 26 | + --method POST \ |
| 27 | + -H "Accept: application/vnd.github+json" \ |
| 28 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 29 | + /repos/${{github.repository}}/issues/${{github.event.number}}/assignees \ |
| 30 | + -f "assignees[]=${{github.actor}}" |
| 31 | +
|
| 32 | + - name: Set default labels |
| 33 | + if: ${{ github.actor != 'dependabot[bot]' }} |
| 34 | + uses: actions/github-script@v7 |
| 35 | + env: |
| 36 | + TITLE: ${{ github.event.pull_request.title }} |
| 37 | + with: |
| 38 | + script: | |
| 39 | + const title = process.env.TITLE; |
| 40 | +
|
| 41 | + let defaultLabels = []; |
| 42 | + if (title.startsWith("feat:")) { |
| 43 | + defaultLabels.push("enhancement"); |
| 44 | + } else if (title.startsWith("fix:")) { |
| 45 | + defaultLabels.push("bug"); |
| 46 | + } else if (title.startsWith("docs:")) { |
| 47 | + defaultLabels.push("documentation"); |
| 48 | + } else if (title.startsWith("test:")) { |
| 49 | + defaultLabels.push("test setup"); |
| 50 | + } else if (title.startsWith("refactor:")) { |
| 51 | + defaultLabels.push("refactoring"); |
| 52 | + } else { |
| 53 | + defaultLabels.push("internal"); |
| 54 | + } |
| 55 | +
|
| 56 | + await github.rest.issues.addLabels({ |
| 57 | + owner: context.repo.owner, |
| 58 | + repo: context.repo.repo, |
| 59 | + issue_number: context.issue.number, |
| 60 | + labels: defaultLabels |
| 61 | + }); |
0 commit comments