Merge branch 'fix/work_flow' into 'master'
fix(workflow): Fix delete-old-artifacts failed See merge request ae_group/esp-box!125
This commit is contained in:
@@ -37,10 +37,32 @@ jobs:
|
||||
delete-old-artifacts:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Delete old artifacts
|
||||
uses: geekyeggo/delete-artifact@v2
|
||||
- name: List and Delete artifacts
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
name: build-images-* # Delete all artifacts with name starting with build-images-
|
||||
script: |
|
||||
const artifacts = await github.rest.actions.listArtifactsForRepo({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
});
|
||||
|
||||
console.log('Found artifacts:', artifacts.data.artifacts.map(a => a.name));
|
||||
|
||||
for (const artifact of artifacts.data.artifacts) {
|
||||
if (artifact.name.startsWith('build-images-')) {
|
||||
console.log(`Deleting artifact: ${artifact.name}`);
|
||||
try {
|
||||
await github.rest.actions.deleteArtifact({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
artifact_id: artifact.id,
|
||||
});
|
||||
console.log(`Successfully deleted: ${artifact.name}`);
|
||||
} catch (error) {
|
||||
console.log(`Failed to delete ${artifact.name}:`, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
job1:
|
||||
needs: [delete-old-artifacts]
|
||||
|
||||
Reference in New Issue
Block a user