Created
February 15, 2018 18:05
-
-
Save eminetto/c98ddff7a1c68cdf4f2d5bcb163b2af0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
export GITHUB_REPO="user/repo" | |
export GITHUB_USERNAME=$(cat ~/.githubrc 2> /dev/null | grep user.login | cut -d ":" -f2 | xargs) | |
export GITHUB_PASSWORD=$(cat ~/.githubrc 2> /dev/null | grep user.password | cut -d ":" -f2 | xargs) | |
if [ -z "$GITHUB_USERNAME" ] | |
then | |
read -p "Type your Github username: " GITHUB_USERNAME | |
echo "user.login: $GITHUB_USERNAME" >> ~/.githubrc | |
fi | |
if [ -z "$GITHUB_PASSWORD" ] | |
then | |
read -p "Type your Github password (won't be shown): " -s GITHUB_PASSWORD | |
echo "user.password: $GITHUB_PASSWORD" >> ~/.githubrc | |
fi | |
read -p "Type the issue id: " ISSUE_ID | |
git checkout master | |
git pull origin master | |
git checkout -b issue-$ISSUE_ID | |
export LABEL="Stage: In progress" | |
response=$(curl -u "$GITHUB_USERNAME:$GITHUB_PASSWORD" -sL "https://api.github.com/repos/$GITHUB_REPO/issues/$ISSUE_ID/labels" -X "POST" -d "[\"$LABEL\"]") | |
if [[ "$response" == *"errors"* ]]; then | |
echo "Error adding label" | |
else | |
echo "Label $LABEL added" | |
fi | |
response=$(curl -u "$GITHUB_USERNAME:$GITHUB_PASSWORD" -sL "https://api.github.com/repos/$GITHUB_REPO/issues/$ISSUE_ID/assignees" -X "POST" -d "{\"assignees\": [\"$GITHUB_USERNAME\"]}") | |
if [[ "$response" == *"errors"* ]]; then | |
echo "Error adding label" | |
else | |
echo "$GITHUB_USERNAME assigned to issue" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment