forked from OWASP/cornucopia
-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (36 loc) · 1.04 KB
/
cleanup-artifacts.yml
File metadata and controls
37 lines (36 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
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,
})
})