Created
March 15, 2018 21:46
-
-
Save lukeledet/83276df47ce8973d18d24bd5960f3d69 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Assign and request a review from someone for a pull request | |
# Requires GITHUB_OAUTH_TOKEN environment variable | |
pr_url="" | |
pr_url_pattern="https://github.com/(.+)/(.+)/pull/(.+)" | |
while read url | |
do | |
pr_url=$url | |
done < /dev/stdin | |
if [[ $pr_url =~ $pr_url_pattern ]] | |
then | |
curl -d "{\"assignees\": [\"$1\"]}" -H "Authorization: token $GITHUB_OAUTH_TOKEN" https://api.github.com/repos/${BASH_REMATCH[1]}/${BASH_REMATCH[2]}/issues/${BASH_REMATCH[3]}/assignees > /dev/null 2>&1 | |
curl -d "{\"reviewers\": [\"$1\"]}" -H "Authorization: token $GITHUB_OAUTH_TOKEN" https://api.github.com/repos/${BASH_REMATCH[1]}/${BASH_REMATCH[2]}/pulls/${BASH_REMATCH[3]}/requested_reviewers > /dev/null 2>&1 | |
else | |
echo "Invalid pull request URL" | |
fi | |
echo $pr_url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment