Skip to content

Instantly share code, notes, and snippets.

@andrewpetrochenkov
Created August 16, 2024 15:26
Show Gist options
  • Save andrewpetrochenkov/37b8c80565166caef706069bb57ec0d8 to your computer and use it in GitHub Desktop.
Save andrewpetrochenkov/37b8c80565166caef706069bb57ec0d8 to your computer and use it in GitHub Desktop.
github API create repo #github
#!/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