File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed
Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,32 @@ jobs:
3737 delete-old-artifacts :
3838 runs-on : ubuntu-latest
3939 steps :
40- - name : Delete old artifacts
41- uses : geekyeggo/delete-artifact@v2
40+ - name : List and Delete artifacts
41+ uses : actions/github-script@v7
4242 with :
43- name : build-images-* # Delete all artifacts with name starting with build-images-
43+ script : |
44+ const artifacts = await github.rest.actions.listArtifactsForRepo({
45+ owner: context.repo.owner,
46+ repo: context.repo.repo,
47+ });
48+
49+ console.log('Found artifacts:', artifacts.data.artifacts.map(a => a.name));
50+
51+ for (const artifact of artifacts.data.artifacts) {
52+ if (artifact.name.startsWith('build-images-')) {
53+ console.log(`Deleting artifact: ${artifact.name}`);
54+ try {
55+ await github.rest.actions.deleteArtifact({
56+ owner: context.repo.owner,
57+ repo: context.repo.repo,
58+ artifact_id: artifact.id,
59+ });
60+ console.log(`Successfully deleted: ${artifact.name}`);
61+ } catch (error) {
62+ console.log(`Failed to delete ${artifact.name}:`, error.message);
63+ }
64+ }
65+ }
4466
4567 job1 :
4668 needs : [delete-old-artifacts]
You can’t perform that action at this time.
0 commit comments