Created
March 20, 2019 03:10
-
-
Save klebercode/b1e3cb34360e5f0428482886fb615998 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