Skip to content

Commit

Permalink
add-to-project workflow: automatically add reviewers without need of …
Browse files Browse the repository at this point in the history
…CODEOWNERS (#37)

## Description

automatically add reviewers without need of CODEOWNERS, reviewers are
added if and only if the PR is not in draft mode.

The recommendation is to start the PR in draft mode, and move it to
ready only when actually ready for review.

While CODEOWNERS is very powerful, it would require to add such file to
all repositories.

## Changes Made

* add specified team as collaborator (default team is `backend-devs`)
* add rowi1de/auto-assign-review-teams@v1.1.3 to add-to-project workflow

## Related Issues

Fixes #38

## Checklist

- [x] I have used a PR title that is descriptive enough for a release
note.
- [x] I have tested these changes locally.
- [x] I have added appropriate tests or updated existing tests.
- [ ] I have tested these changes on a dedicated VM or a customer VM
[name of the VM]
- [x] I have added appropriate documentation or updated existing
documentation.

---------

Co-authored-by: Bot <bot@zaphiro.ch>
  • Loading branch information
chicco785 and Bot authored Sep 28, 2023
1 parent be6a4f3 commit 087c177
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/add-to-project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
branches: [ main ]
types:
- labeled
- ready_for_review
workflow_call:
inputs:
labeled:
Expand All @@ -16,6 +17,13 @@ on:
project-url:
required: false
type: string
reviewers-team:
required: false
default: 'backend-devs'
type: string
reviewers-individuals:
required: false
type: string
jobs:
add-to-project:
name: Add issue/PR to a project
Expand All @@ -37,3 +45,29 @@ jobs:
if: github.event_name == 'pull_request'
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
add-reviewer-to-pr:
name: Assign Reviewer to PR
runs-on: ubuntu-latest
permissions: write-all
steps:
- if: github.event_name == 'pull_request'
run: |
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/orgs/$OWNER/teams/$TEAM/repos/$OWNER/$REPO \
-f permission='push'
env:
GITHUB_TOKEN: ${{ secrets.REPO_PAT }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
TEAM: ${{ inputs.reviewers-team != '' && inputs.reviewers-team || 'backend-devs' }}
- if: github.event_name == 'pull_request'
uses: rowi1de/auto-assign-review-teams@v1.1.3
with:
repo-token: ${{ secrets.REPO_PAT }}
teams: ${{ inputs.reviewers-team != '' && inputs.reviewers-team || 'backend-devs' }} # only works for GitHub Organisation/Teams
persons: ${{ inputs.reviewers-individuals }} # add individual persons here
include-draft: false # Draft PRs will be skipped (default: false)
skip-with-manual-reviewers: 1 # Skip this action, if the number of reviwers was already assigned (default: 0)
4 changes: 3 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ The repository includes:
issue or PR is added to a repository, it is also added - by default - to the
[SynchroHub platform project](https://github.com/orgs/zaphiro-technologies/projects/2)
or to the project defined by `project-url` input parameter with status `new`.
When a new PR is added, the PR is assigned to its creator.
When a new PR is added, the PR is assigned to its creator. When a PR is set to
ready, reviewers from `reviewers-team` input parameter (default value
'backend-devs') or `reviewers-individuals` (comma separated) are added.
- [check-pr](.github/workflows/check-pr.yaml) workflow: when a new PR is added
to a repository or any change occurs to the pr, the pr is validated to be sure
that labels are valid.
Expand Down
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Features

- add-to-project workflow: automatically add reviewers without need of
CODEOWNERS (PR #37 by @chicco785)
- add-to-project workflow: automatically assign pr to its creator (PR #36 by
@chicco785)
- add-to-project workflow: make project url configurable as input parameter (PR
Expand Down

0 comments on commit 087c177

Please sign in to comment.