Skip to content

Commit ebf783c

Browse files
committed
fix: delete release again if failed with "405 Not Allowed" (3 times)
1 parent f131e33 commit ebf783c

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/gitHubPublisher.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,25 @@ export class GitHubPublisher implements Publisher {
141141
}
142142

143143
//noinspection JSUnusedGlobalSymbols
144-
deleteRelease(): BluebirdPromise<void> {
145-
if (this._releasePromise.isFulfilled()) {
146-
return gitHubRequest<void>(`/repos/${this.owner}/${this.repo}/releases/${this._releasePromise.value().id}`, this.token, null, "DELETE")
147-
}
148-
else {
144+
async deleteRelease(): Promise<void> {
145+
if (!this._releasePromise.isFulfilled()) {
149146
return BluebirdPromise.resolve()
150147
}
148+
149+
for (let i = 0; i < 3; i++) {
150+
try {
151+
return await
152+
gitHubRequest<void>(`/repos/${this.owner}/${this.repo}/releases/${this._releasePromise.value().id}`, this.token, null, "DELETE")
153+
}
154+
catch (e) {
155+
if (e instanceof HttpError && (e.response.statusCode === 405 || e.response.statusCode === 502)) {
156+
continue
157+
}
158+
159+
throw e
160+
}
161+
}
162+
163+
log("WARN: Cannot delete release " + this._releasePromise.value().id)
151164
}
152165
}

0 commit comments

Comments
 (0)