Skip to content

Instantly share code, notes, and snippets.

@mgramin
Created April 4, 2019 11:38
Show Gist options
  • Select an option

  • Save mgramin/1785c0af3d1e297b351be86d29ef5640 to your computer and use it in GitHub Desktop.

Select an option

Save mgramin/1785c0af3d1e297b351be86d29ef5640 to your computer and use it in GitHub Desktop.
Delete all GitHub releases and tags
import requests
from requests import Response
from requests.auth import HTTPBasicAuth
releases_url = 'https://api.github.com/repos/sql-boot/sql-boot/releases'
for o in requests.get(releases_url).json():
print(o['id'])
delete = requests.delete(releases_url + '/' + str(o['id']), auth=HTTPBasicAuth('USER', 'PASSWORD'))
print(releases_url + '/' + str(o['id']))
print(delete.status_code)
tags_url = 'https://api.github.com/repos/sql-boot/sql-boot/tags'
for o in requests.get(tags_url).json():
print(o['name'])
delete = requests.delete('https://api.github.com/repos/sql-boot/sql-boot/git/refs/tags/' + str(o['name']), auth=HTTPBasicAuth('USER', 'PASSWORD'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment