Created
August 16, 2024 15:26
-
-
Save andrewpetrochenkov/37b8c80565166caef706069bb57ec0d8 to your computer and use it in GitHub Desktop.
github API create repo #github
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
#!/usr/bin/env python | |
import json | |
import os | |
import requests | |
NAME = os.getcwd().split('/')[-1] | |
URL = 'https://api.github.com/user/repos' | |
headers = { | |
"Authorization": "Bearer %s" % os.getenv("GITHUB_TOKEN"), | |
} | |
r = requests.post(URL,headers=headers,data=json.dumps({'name':NAME})) | |
if r.status_code not in [201]: | |
r.raise_for_status() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment