Skip to content

Instantly share code, notes, and snippets.

View aholmis's full-sized avatar

Anders Johan Holmefjord aholmis

  • Norway
View GitHub Profile
@aholmis
aholmis / clean-artifacts.ps1
Created May 21, 2026 16:17
Powershell script to delete artifacts older than N days in a GitHub repo
# 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) {