Skip to content

Commit

Permalink
Merge pull request #11 from lionel1704/update-v2
Browse files Browse the repository at this point in the history
Update to actions v2
  • Loading branch information
abinoda authored Oct 10, 2019
2 parents 1fb6f73 + e297aa4 commit 89b0281
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ If your team currently uses pull request assignees but would like to switch to

## Usage

This Action subscribes to [Pull request events](https://developer.github.com/v3/activity/events/types/#pullrequestevent) which fire whenever users are assigned or unassigned to pull requests.
This Action subscribes to [Pull request events](https://help.github.com/en/articles/events-that-trigger-workflows#pull-request-event-pull_request) specifically the `assigned` and `unassigned` events which fire whenever users are assigned or unassigned to pull requests.

```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"
]
# add this line if you want to continue running parallel github actions even if this action is skipped/not needed
env = {
REVIEWERS_UNMODIFIED_EXIT_CODE = "0"
}
}
name: Assign reviewers based on assignees
on:
pull_request:
types: [assigned, unassigned]
jobs:
assignee_to_reviewer:
runs-on: ubuntu-latest
steps:
- name: Assignee to Reviewer
uses: pullreminders/assignee-to-reviewer-action@v1.0.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

Note that the workflow for `pull_request` events will be triggered by default only for `opened`, `synchronize` or `reopened` activity types. For other, events the `types` keyword must be used.

## Demo

<img src="https://github.com/pullreminders/assignee-to-reviewer-action/raw/master/docs/images/example.png" width="540">
Expand Down
10 changes: 2 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [[ -z "$GITHUB_TOKEN" ]]; then
fi

if [[ -z "$GITHUB_EVENT_NAME" ]]; then
echo "Set the GITHUB_REPOSITORY env variable."
echo "Set the GITHUB_EVENT_NAME env variable."
exit 1
fi

Expand All @@ -23,12 +23,6 @@ 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")

# Github Actions will mark a check as "neutral" (neither failed/succeeded) when you exit with code 78
# But this will terminate any other Actions running in parallel in the same workflow.
# Configuring this Environment Variable `REVIEWERS_UNMODIFIED_EXIT_CODE=0` if no reviewer was added or deleted.
# Docs: https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#exit-codes-and-statuses
REVIEWERS_UNMODIFIED_EXIT_CODE=${REVIEWERS_UNMODIFIED_EXIT_CODE:-78}

update_review_request() {
curl -sSL \
-H "Content-Type: application/json" \
Expand All @@ -45,5 +39,5 @@ elif [[ "$action" == "unassigned" ]]; then
update_review_request 'DELETE'
else
echo "Ignoring action ${action}"
exit "$REVIEWERS_UNMODIFIED_EXIT_CODE"
exit 0
fi

0 comments on commit 89b0281

Please sign in to comment.