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
| # Define how many days old the artifacts should be | |
| $DaysOld = 30 | |
| $CutoffDate = (Get-Date).AddDays(-$DaysOld) | |
| # Get the list of all artifacts in the current repository | |
| $artifacts = (gh api -H "Accept: application/vnd.github+json" -X GET "repos/{user}/{repo}/actions/artifacts?per_page=50&page=1") | ConvertFrom-Json | |
| Write-Host "Total" $artifacts.total_count | |
| # Loop through each artifact and delete if it's older than the cutoff | |
| foreach ($artifact in $artifacts.artifacts) { |