Skip to content

Cleanup Artifacts

Cleanup Artifacts #54

name: Cleanup Artifacts
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Delete old artifacts
uses: actions/github-script@v7
with:
script: |
const artifacts = await github.rest.actions.listArtifactsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100
});
for (const artifact of artifacts.data.artifacts) {
console.log(`Deleting ${artifact.name} (${artifact.size_in_bytes} bytes)`);
await github.rest.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id
});
}