-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ff0d749
Showing
7 changed files
with
118 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,6 @@ | ||
# ignore all files by default | ||
* | ||
# include required files with an exception | ||
!entrypoint.sh | ||
!LICENSE | ||
!README.md |
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 @@ | ||
.DS_Store |
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,18 @@ | ||
FROM debian:9.6-slim | ||
|
||
LABEL "com.github.actions.name"="GitHub Action for Assignee to Reviewer" | ||
LABEL "com.github.actions.description"="Create review rrequests based on assignees." | ||
LABEL "com.github.actions.icon"="arrow-up-right" | ||
LABEL "com.github.actions.color"="white" | ||
|
||
LABEL version="1.0.0" | ||
LABEL repository="http://github.com/pullreminders/assignee-to-reviewer-action" | ||
LABEL homepage="http://github.com/pullreminders/assignee-to-reviewer-action" | ||
LABEL maintainer="Abi Noda <abi@pullreminders.com>" | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
curl \ | ||
jq | ||
|
||
ADD entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Nicolas Coutin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,29 @@ | ||
# GitHub Action for Assignee to Reviewer | ||
|
||
If your team currently uses pull request Assignees but would like to switch to [Review Requests](https://blog.github.com/2016-12-07-introducing-review-requests/), having everyone change their workflows can be difficult. This GitHub Action eases the transition by automatically creating and removing review requests based on Assignees. | ||
|
||
## Usage | ||
|
||
This Action is used by subscribing to [Issues events](https://developer.github.com/v3/activity/events/types/#issuesevent) which are triggered whenever Assigness are added or removed. | ||
|
||
```workflow | ||
workflow "Assign reviewers based on assignees" { | ||
on = "pull_request" | ||
resolves = ["Assignee to reviewer"] | ||
} | ||
action "Assignee to reviewer" { | ||
uses = "pullreminders/assignee-to-reviewer-action@master" | ||
secrets = [ | ||
"GITHUB_TOKEN" | ||
] | ||
} | ||
``` | ||
|
||
## Demo | ||
|
||
<img src="https://github.com/pullreminders/assignee-to-reviewer-action/raw/master/docs/images/example.png" width="540"> | ||
|
||
## License | ||
|
||
The Dockerfile and associated scripts and documentation in this project are released under the [MIT License](LICENSE). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,43 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
if [[ -z "$GITHUB_TOKEN" ]]; then | ||
echo "Set the GITHUB_TOKEN env variable." | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$GITHUB_EVENT_NAME" ]]; then | ||
echo "Set the GITHUB_REPOSITORY env variable." | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$GITHUB_EVENT_PATH" ]]; then | ||
echo "Set the GITHUB_EVENT_PATH env variable." | ||
exit 1 | ||
fi | ||
|
||
API_HEADER="Accept: application/vnd.github.v3+json; application/vnd.github.antiope-preview+json" | ||
AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}" | ||
|
||
action=$(jq --raw-output .action "$GITHUB_EVENT_PATH") | ||
number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") | ||
assignee=$(jq --raw-output .assignee.login "$GITHUB_EVENT_PATH") | ||
|
||
update_review_request() { | ||
curl -sSL \ | ||
-H "Content-Type: application/json" \ | ||
-H "${AUTH_HEADER}" \ | ||
-H "${API_HEADER}" \ | ||
-X $1 \ | ||
-d "{\"reviewers\":[\"${assignee}\"]}" \ | ||
"https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${number}/requested_reviewers" | ||
} | ||
|
||
if [[ "$action" == "assigned" ]]; then | ||
update_review_request 'POST' | ||
elif [[ "$action" == "unassigned" ]]; then | ||
update_review_request 'DELETE' | ||
else | ||
echo "Ignoring action ${action}" | ||
exit 78 | ||
fi |