From d69110bc97926c5b695142b87b27b77591c25453 Mon Sep 17 00:00:00 2001 From: mrroot5 Date: Mon, 6 Oct 2025 13:25:18 +0200 Subject: [PATCH] Added PR autofill github action --- .github/workflows/pr-autofill-information.yml | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 .github/workflows/pr-autofill-information.yml diff --git a/.github/workflows/pr-autofill-information.yml b/.github/workflows/pr-autofill-information.yml new file mode 100644 index 0000000..e00ee7c --- /dev/null +++ b/.github/workflows/pr-autofill-information.yml @@ -0,0 +1,110 @@ +name: Label, Assignee and Set PR Title + +on: + pull_request: + types: [opened] + +jobs: + set-title: + if: | + (github.event_name == 'pull_request' && github.event.pull_request.draft == false) + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/github-script@v7 + with: + script: | + const branch = context.payload.pull_request.head.ref; + const [prefix, ...rest] = branch.split('-'); + const title = `${prefix.charAt(0).toUpperCase() + prefix.slice(1)}: ${rest.join(' ')}`; + + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + title, + assignees: [context.repo.owner] + }); + + assign-owner: + if: | + (github.event_name == 'pull_request' && github.event.pull_request.draft == false) + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions-ecosystem/action-add-assignees@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + assignees: ${{ github.repository_owner }} + + labels: + if: | + (github.event_name == 'pull_request' && github.event.pull_request.draft == false) + runs-on: ubuntu-latest + permissions: + pull-requests: write + issues: write + steps: + # Bugfix labels + - if: startsWith(github.event.pull_request.head.ref, 'bugfix') || startsWith(github.event.pull_request.head.ref, 'fix') + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: | + bug + python + + # Enhancement labels + - if: startsWith(github.event.pull_request.head.ref, 'feature') || startsWith(github.event.pull_request.head.ref, 'enhancement') + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: | + enhancement + python + + # Style labels + - if: startsWith(github.event.pull_request.head.ref, 'style') || startsWith(github.event.pull_request.head.ref, 'format') + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: | + style + python + + # Build labels + - if: startsWith(github.event.pull_request.head.ref, 'build') + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: | + build + + # Dependencies labels + - if: startsWith(github.event.pull_request.head.ref, 'dependabot') + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: | + dependencies + python + + # Documentation labels + - if: startsWith(github.event.pull_request.head.ref, 'docs') + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: | + documentation + python + + # Documentation labels + - if: startsWith(github.event.pull_request.head.ref, 'refactor') + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: | + refactor + python + + # Reopened PR labels + - if: github.event.action == 'reopened' + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: | + reopen