Last active
January 4, 2021 13:38
-
-
Save turboBasic/f39f93e36db2b520708ad072217dc0b4 to your computer and use it in GitHub Desktop.
create Github repo from command line using Github REST API with correct escaping #shell #git #github
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/sh | |
# Create repository in Github with correct escaping in repo name | |
# Requires {@code GITHUB_TOKEN} env var. | |
# @return ssh url to created repository which can be used in git clone command | |
jq --null-input --compact-output \ | |
--arg repo 'my-awesome-project' \ | |
'{name: $repo}' \ | |
| curl \ | |
--header "Authorization: token $GITHUB_TOKEN" \ | |
--data @- \ | |
https://api.github.com/user/repos \ | |
| jq --raw-output .ssh_url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment