diff --git a/.github/actions/prs_user_limit/action.yml b/.github/actions/prs_user_limit/action.yml new file mode 100644 index 0000000000000..1dd0d2c830902 --- /dev/null +++ b/.github/actions/prs_user_limit/action.yml @@ -0,0 +1,39 @@ +name: 'Limit PRs open per user' +description: 'Get all changed files in a Pull Request' +author: 'danimtb' +inputs: + files: + description: "Limit the number of open pull-request that user can have open at the same time" + required: false + default: "" + limit: + description: "Maximum number of PRs an author can open" + required: true + default: "10" + comment: + description: "Comment to post in the github PR when the limit of open PRs is reached" + required: true + default: "This is a comment" +runs: + using: "composite" + steps: + - uses: actions/github-script@v6 + with: + script: | + const creator = context.payload.sender.login + const opts = github.rest.issues.listForRepo.endpoint.merge({ + ...context.issue, + creator, + is: 'pr' + state: 'open', + sort: 'created', + order: 'asc' + }) + const prs = await github.paginate(opts) + + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: Your number of PRs open is ${{ prs.length }} :wink:` + }) diff --git a/.github/workflows/prs-user-limit.yml b/.github/workflows/prs-user-limit.yml new file mode 100644 index 0000000000000..719546fdbc975 --- /dev/null +++ b/.github/workflows/prs-user-limit.yml @@ -0,0 +1,18 @@ +name: "[service] Alert Community" + +on: + pull_request_target: + types: [opened] + +env: + PYVER: "3.10" + +jobs: + comment: + # if: github.repository == 'conan-io/conan-center-index' + runs-on: ubuntu-latest + steps: + - uses: ./.github/actions/prs_user_limit + with: + limit: 27 + comment: "my comment"