diff --git a/.github/workflows/check-pr-author.yml b/.github/workflows/check-pr-author.yml new file mode 100644 index 00000000..38dc3696 --- /dev/null +++ b/.github/workflows/check-pr-author.yml @@ -0,0 +1,31 @@ +name: Check PR Author for Merge Permission + +on: + pull_request: + types: [opened, synchronize, reopened] # Trigger on new PRs or updates + +permissions: + statuses: write + pull-requests: read + +jobs: + check-author: + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v7 + with: + script: | + const allowedUsers = ['keone', 'NoahMarconi', 'AustinGreen', 'kristovatlas', 'therealharpaljadeja', 'nishuzumi', 'portdeveloper']; // Keone, Security Team, Head of Eng, DevRel + const prAuthor = context.payload.pull_request.user.login; + const state = allowedUsers.includes(prAuthor) ? 'success' : 'failure'; + const description = allowedUsers.includes(prAuthor) ? 'PR author is allowed to merge' : 'PR author not allowed to merge'; + + await github.rest.repos.createCommitStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + sha: context.payload.pull_request.head.sha, + state: state, + context: 'merge-allowed-check', // Custom name for the status check + description: description + }); +