Skip to content

Instantly share code, notes, and snippets.

@matt40k
Last active August 15, 2016 11:51
Show Gist options
  • Save matt40k/8ca025a7b260ce59a0d9a9a461479ac8 to your computer and use it in GitHub Desktop.
Save matt40k/8ca025a7b260ce59a0d9a9a461479ac8 to your computer and use it in GitHub Desktop.
Remove duff releases
$url = 'https://api.github.com/repos/simsbulkimport/simsbulkimport/releases'
$apiKey = '{{removed}}'
$header = @{"Authorization"="token "+ $apiKey}
$i = 1
do {
#$content = @{tag_name="v1.0.0";target_commitish="master";name="v1.0.0";body="Description of the release";draft=$false;prerelease=$false} | ConvertTo-Json
$r = Invoke-WebRequest -Uri $url -Method GET -Headers $header -Body $content
$items = $r.Content | ConvertFrom-Json
Write-Host $items.count
foreach ($item in $items)
{
if ($item.prerelease -ieq 'True')
{
$id = $item.id
$durl = "$url/$id"
#Write-Host $durl
$dal = "$durl/assets"
$assests = Invoke-WebRequest -Uri $dal -Method GET -Headers $header
$aitems = $assests.Content | ConvertFrom-Json
foreach ($assest in $aitems)
{
$assessId = $assest.id
$dau = "$url/assets/$assessId"
Write-Host $dau
$da = Invoke-WebRequest -Uri $dau -Method DELETE -Headers $header
}
$dr = Invoke-WebRequest -Uri $durl -Method DELETE -Headers $header
#Write-Host $dr.StatusCode
}
}
$i++}
until ($i -gt 100)
$url = 'https://api.github.com/repos/simsbulkimport/simsbulkimport'
$apiKey = '{{removed}}'
$header = @{"Authorization"="token "+ $apiKey}
$proxy = "http://proxy:8080"
$i = 1
do {
$urlTags = "$url/tags"
$r = Invoke-WebRequest -Uri $url -Method GET -Headers $header -Body $content -Proxy $proxy -ProxyUseDefaultCredentials
$items = $r.Content | ConvertFrom-Json
Write-Host $items.count
foreach ($item in $items)
{
$tag = $item.name
if ($item.commit.sha -eq 'db215f3df3e587d1edd2fd9f2105bd3d5ac17a6e') # Change for the affected Commit id
{
Write-Host $tag
$urlTag = "$url/git/refs/tags/$tag"
$delTag = Invoke-WebRequest -Uri $urlTag -Method DELETE -Headers $header -Proxy $proxy -ProxyUseDefaultCredentials
}
}
$i++}
until ($i -gt 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment