@@ -3530,6 +3530,7 @@ const core = __importStar(__webpack_require__(470));
3530
3530
const github = __importStar(__webpack_require__(469));
3531
3531
const create_1 = __webpack_require__(646);
3532
3532
const finish_1 = __webpack_require__(209);
3533
+ const delete_all_1 = __webpack_require__(832);
3533
3534
// nullify getInput empty results
3534
3535
// to allow coalescence ?? operator
3535
3536
function getInput(name, options) {
@@ -3588,23 +3589,28 @@ function run() {
3588
3589
}
3589
3590
catch (error) {
3590
3591
core.error(error);
3591
- // core.setFailed(error)
3592
3592
throw error;
3593
3593
}
3594
3594
break;
3595
3595
case 'finish':
3596
3596
try {
3597
- yield finish_1.finish(client, deploymentId, status, logsUrl, environmentUrl);
3597
+ yield finish_1.finish(client, Number( deploymentId) , status, logsUrl, environmentUrl);
3598
3598
}
3599
3599
catch (error) {
3600
3600
core.error(error);
3601
- // core.setFailed(`Could not finish a deployment: ${JSON.stringify(error, null, 2)}`)
3602
3601
throw error;
3603
3602
}
3604
3603
break;
3605
3604
case 'delete':
3606
3605
break;
3607
3606
case 'delete-all':
3607
+ try {
3608
+ yield delete_all_1.deleteAll(client, environment);
3609
+ }
3610
+ catch (error) {
3611
+ core.error(error);
3612
+ throw error;
3613
+ }
3608
3614
break;
3609
3615
}
3610
3616
});
@@ -3635,7 +3641,7 @@ exports.finish = void 0;
3635
3641
const github_1 = __webpack_require__(469);
3636
3642
function finish(client, deploymentId, status, logUrl, environmentUrl) {
3637
3643
return __awaiter(this, void 0, void 0, function* () {
3638
- const statusResult = yield client.repos.createDeploymentStatus(Object.assign(Object.assign({}, github_1.context.repo), { deployment_id: Number( deploymentId) , state: status, log_url: logUrl, environment_url: environmentUrl }));
3644
+ const statusResult = yield client.repos.createDeploymentStatus(Object.assign(Object.assign({}, github_1.context.repo), { deployment_id: deploymentId, state: status, log_url: logUrl, environment_url: environmentUrl }));
3639
3645
console.log(`created deployment status: ${JSON.stringify(statusResult.data, null, 2)}`);
3640
3646
});
3641
3647
}
@@ -9467,6 +9473,42 @@ function sync (path, options) {
9467
9473
}
9468
9474
9469
9475
9476
+ /***/ }),
9477
+
9478
+ /***/ 832:
9479
+ /***/ (function(__unusedmodule, exports, __webpack_require__) {
9480
+
9481
+ "use strict";
9482
+
9483
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9484
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9485
+ return new (P || (P = Promise))(function (resolve, reject) {
9486
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
9487
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9488
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9489
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9490
+ });
9491
+ };
9492
+ Object.defineProperty(exports, "__esModule", { value: true });
9493
+ exports.deleteAll = void 0;
9494
+ const github_1 = __webpack_require__(469);
9495
+ function deleteAll(client, environment) {
9496
+ return __awaiter(this, void 0, void 0, function* () {
9497
+ const deployments = yield client.repos.listDeployments(Object.assign(Object.assign({}, github_1.context.repo), { environment }));
9498
+ yield Promise.all(deployments.data.map((deployment) => __awaiter(this, void 0, void 0, function* () {
9499
+ // invalidate deployment first
9500
+ // since we can't delete active deployment
9501
+ console.log(`invalidate deployment: ${deployment.id}`);
9502
+ yield client.repos.createDeploymentStatus(Object.assign(Object.assign({}, github_1.context.repo), { deployment_id: deployment.id, state: 'failure' }));
9503
+ // then delete it
9504
+ console.log(`delete deployment: ${deployment.url}`);
9505
+ yield client.request(deployment.url, { method: 'DELETE' });
9506
+ })));
9507
+ });
9508
+ }
9509
+ exports.deleteAll = deleteAll;
9510
+
9511
+
9470
9512
/***/ }),
9471
9513
9472
9514
/***/ 835:
0 commit comments