Skip to content

Instantly share code, notes, and snippets.

@leo-bianchi
Last active May 23, 2019 15:18
Show Gist options
  • Save leo-bianchi/fa92f74803261425a32261640bd825e7 to your computer and use it in GitHub Desktop.
Save leo-bianchi/fa92f74803261425a32261640bd825e7 to your computer and use it in GitHub Desktop.
Consuming Github API to create remote REPO #bash #github
#!/bin/bash
# Create a remote repository using github API
read -p "Type the repo name, and press [ENTER]:" repo_name
read -p "Type repo description, and press [ENTER]:" repo_desc
printf "REPOSITORY NAME: $repo_name\nREPOSITORY DESCRIPTION: $repo_desc\n"
# Confirmation
while true; do
read -p "Do you wish to create the repo?(y/n)" yn
case $yn in
[Yy]* ) curl -u 'username' https://api.github.com/user/repos -d '{"name":"'"$repo_name"'", "description":"'"$repo_desc"'"}'
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment