Skip to content

Cleanup artifacts

Cleanup artifacts #1

name: Cleanup artifacts
on:
workflow_call:
workflow_dispatch:
permissions:
contents: read
jobs:
hardening:
name: Harden runner
uses: ./.github/workflows/hardening.yaml
cleanup:
permissions:
# Required to delete artifact, otherwise you'll get
# "Error: Resource not accessible by integration"
contents: write
name: Run Tests
needs: hardening
runs-on: ubuntu-latest
steps:
- name: Delete Old Artifacts
uses: actions/github-script@v6
id: artifact
with:
script: |
const res = await github.rest.actions.listArtifactsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
})
res.data.artifacts
.forEach(({ id }) => {
github.rest.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: id,
})
})