Skip to content

Commit

Permalink
ci: add reviewers workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Callahan Kovacs <[email protected]>
  • Loading branch information
mr-cal committed Jun 11, 2024
1 parent 6aa3696 commit 1740edb
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/add-reviewer-label.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Add `needs-starcraft-review` if starcraft-reviewers is added as a reviewer

name: add-reviewer-label

on:
pull_request:
types:
- review_requested

jobs:
add-reviewer-label:
runs-on: ubuntu-latest
steps:
- name: Add 'needs-starcraft-review' label
uses: octokit/request-action@v2
with:
route: POST /repos/${{ github.repository }}/issues/$ {{ github.event.pull_request.number }}/labels
mediaType: 'application/vnd.github.v3+json'
token: ${{ secrets.GITHUB_TOKEN }}
labels: need-starcraft-review
39 changes: 39 additions & 0 deletions .github/workflows/add-reviewers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# If there are not 2 reviews, re-add starcraft-reviewers when reviewed by the starcraft-reviewers team
# Otherwise, drop the `need-starcraft-review` label

name: add-reviewer

on:
pull_request_review:
types: [submitted]

jobs:
add-reviewer:
runs-on: ubuntu-latest

steps:
- name: check number of reviews
id: check-reviews
uses: octokit/request-action@v2
with:
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews
mediaType: 'application/vnd.github.v3+json'
token: ${{ secrets.GITHUB_TOKEN }}

- name: re-add team if there are not enough reviews
if: steps.check-reviews.outputs.data | fromJson | length < 2
uses: octokit/request-action@v2
with:
route: POST /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers
mediaType: 'application/vnd.github.v3+json'
token: ${{ secrets.GITHUB_TOKEN }}
reviewers: starcraft-reviewers

- name: drop label if there are enough reviews
if: steps.check-reviews.outputs.data | fromJson | length >= 2
uses: octokit/request-action@v2
with:
route: DELETE /repos/${{ github.repository }}/issues/$ {{ github.event.pull_request.number }}/labels
mediaType: 'application/vnd.github.v3+json'
token: ${{ secrets.GITHUB_TOKEN }}
labels: need-starcraft-review

0 comments on commit 1740edb

Please sign in to comment.