Fixes #120 Artifacts can be removed even when new ones aren't provided

This commit is contained in:
Nick Cipollo
2021-10-03 17:58:09 -04:00
parent 821cbcc349
commit 95aae1ba96
8 changed files with 164 additions and 45 deletions

View File

@@ -10,7 +10,6 @@ export class GithubArtifactUploader implements ArtifactUploader {
constructor(
private releases: Releases,
private replacesExistingArtifacts: boolean = true,
private removeArtifacts: boolean = false,
private throwsUploadErrors: boolean = false,
) {
}
@@ -21,9 +20,6 @@ export class GithubArtifactUploader implements ArtifactUploader {
if (this.replacesExistingArtifacts) {
await this.deleteUpdatedArtifacts(artifacts, releaseId)
}
if (this.removeArtifacts) {
await this.deleteUploadedArtifacts(releaseId)
}
for (const artifact of artifacts) {
await this.uploadArtifact(artifact, releaseId, uploadUrl)
}
@@ -69,13 +65,4 @@ export class GithubArtifactUploader implements ArtifactUploader {
}
}
}
private async deleteUploadedArtifacts(releaseId: number): Promise<void> {
const releaseAssets = await this.releases.listArtifactsForRelease(releaseId)
for (const artifact of releaseAssets) {
const asset = artifact
core.debug(`Deleting existing artifact ${artifact.name}...`)
await this.releases.deleteArtifact(asset.id)
}
}
}