Last active
August 15, 2016 11:51
-
-
Save matt40k/8ca025a7b260ce59a0d9a9a461479ac8 to your computer and use it in GitHub Desktop.
Remove duff releases
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
$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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment