Skip to content

Commit

Permalink
update clean script
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenegriffin committed Nov 14, 2024
1 parent 00b8366 commit 095eaa3
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions scripts/cleancodeql.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ function Delete-CodeQLAnalysisLoop {

Write-Host "Request: $analysisUrl"

# Create the headers for the API request
$headers = @{
"Authorization" = "token $token"
"Accept" = "application/vnd.github+json"
"X-GitHub-Api-Version" = "2022-11-28"
}

# Send the DELETE request to the GitHub API
$response = gh api --method DELETE -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" $analysisUrl

Expand Down Expand Up @@ -46,15 +39,15 @@ function Delete-CodeQLAnalysis {
}

# Fetch the analyses using the GitHub CLI
$analyses = gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/microsoft/mfcmapi/code-scanning/analyses --paginate
$analyses = gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/$owner/$repo/code-scanning/analyses --paginate

# Convert the response to JSON
$analysesJson = $analyses | ConvertFrom-Json

# Loop over the analyses and write the ID when deletable is true
foreach ($analysis in $analysesJson) {
if ($analysis.deletable -eq $true) {
Write-Output "Deletable analysis ID: $($analysis.id)"
Write-Output "Deletable analysis url: $($analysis.url)"
Delete-CodeQLAnalysis -analysisUrl "$($analysis.url)?confirm_delete"
}
}

0 comments on commit 095eaa3

Please sign in to comment.