forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GitHub][workflows] Ask reviewers to merge PRs when author cannot (ll…
…vm#81142) This uses https://pygithub.readthedocs.io/en/stable/github_objects/Repository.html?highlight=get_collaborator_permission#github.Repository.Repository.get_collaborator_permission. Which does https://docs.github.com/en/rest/collaborators/collaborators?apiVersion=2022-11-28#get-repository-permissions-for-a-user and returns the top level "permission" key. This is less detailed than the user/permissions key but should be fine for this use case. When a review is submitted we check: * If it's an approval. * Whether we have already left a merge on behalf comment (by looking for a hidden HTML comment). * Whether the author has permissions to merge their own PR. * Whether the reviewer has permissions to merge. If needed we leave a comment tagging the reviewer. If the reviewer also doesn't have merge permission, then it asks them to find someone else who does.
- Loading branch information
1 parent
5e5e51e
commit 38c706e
Showing
2 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: "Prompt reviewers to merge PRs on behalf of authors" | ||
|
||
permissions: | ||
contents: read | ||
|
||
on: | ||
pull_request_review: | ||
types: | ||
- submitted | ||
|
||
jobs: | ||
merge-on-behalf-information-comment: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
if: >- | ||
(github.repository == 'llvm/llvm-project') && | ||
(github.event.review.state == 'APPROVED') | ||
steps: | ||
- name: Checkout Automation Script | ||
uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: llvm/utils/git/ | ||
ref: main | ||
|
||
- name: Setup Automation Script | ||
working-directory: ./llvm/utils/git/ | ||
run: | | ||
pip install -r requirements.txt | ||
- name: Add Merge On Behalf Comment | ||
working-directory: ./llvm/utils/git/ | ||
run: | | ||
python3 ./github-automation.py \ | ||
--token '${{ secrets.GITHUB_TOKEN }}' \ | ||
pr-merge-on-behalf-information \ | ||
--issue-number "${{ github.event.pull_request.number }}" \ | ||
--author "${{ github.event.pull_request.user.login }}" \ | ||
--reviewer "${{ github.event.review.user.login }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters