Skip to content

Commit

Permalink
Merge pull request #493 from OWASP/short-expiry-on-pull-requests
Browse files Browse the repository at this point in the history
Add job for manually deleting artifacts.
  • Loading branch information
sydseter committed May 8, 2024
2 parents a4e1674 + 7be0143 commit 0c0766c
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/cleanup-artifacts.yml
@@ -0,0 +1,37 @@
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,
})
})

0 comments on commit 0c0766c

Please sign in to comment.