@@ -3525,9 +3525,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
3525
3525
});
3526
3526
};
3527
3527
Object.defineProperty(exports, "__esModule", { value: true });
3528
+ exports.run = void 0;
3528
3529
const core = __importStar(__webpack_require__(470));
3529
3530
const github = __importStar(__webpack_require__(469));
3530
3531
const create_1 = __webpack_require__(646);
3532
+ const finish_1 = __webpack_require__(209);
3531
3533
// nullify getInput empty results
3532
3534
// to allow coalescence ?? operator
3533
3535
function getInput(name, options) {
@@ -3544,7 +3546,7 @@ function run() {
3544
3546
let type;
3545
3547
let logsUrl;
3546
3548
let description;
3547
- let initialStatus ;
3549
+ let status ;
3548
3550
let environment;
3549
3551
let environmentUrl;
3550
3552
let deploymentId;
@@ -3561,15 +3563,16 @@ function run() {
3561
3563
console.log(`logs: ${logsUrl}`);
3562
3564
description = (_c = getInput('description')) !== null && _c !== void 0 ? _c : `deployed by ${actor}`;
3563
3565
console.log(`description: ${description}`);
3564
- initialStatus = ((_d = getInput('initial_status ')) !== null && _d !== void 0 ? _d : 'in_progress');
3565
- console.log(`initialStatus : ${initialStatus }`);
3566
+ status = ((_d = getInput('status ')) !== null && _d !== void 0 ? _d : 'in_progress');
3567
+ console.log(`status : ${status }`);
3566
3568
// default to branch name w/o `deploy-` prefix
3567
3569
environment = (_e = getInput('environment')) !== null && _e !== void 0 ? _e : ref.replace('refs/heads/', '').replace(/^deploy-/, '');
3568
3570
console.log(`environment: ${environment}`);
3569
3571
environmentUrl = (_f = getInput('environment_url')) !== null && _f !== void 0 ? _f : '';
3570
3572
console.log(`environmentUrl: ${environmentUrl}`);
3571
- const shouldRequireDeploymentId = type === 'status ' || type === 'delete';
3573
+ const shouldRequireDeploymentId = type === 'finish ' || type === 'delete';
3572
3574
deploymentId = (_g = getInput('deployment_id', { required: shouldRequireDeploymentId })) !== null && _g !== void 0 ? _g : '0';
3575
+ console.log(`deploymentId: ${deploymentId}`);
3573
3576
}
3574
3577
catch (error) {
3575
3578
core.error(error);
@@ -3579,19 +3582,64 @@ function run() {
3579
3582
const client = new github.GitHub(token, { previews: ['ant-man', 'flash'] });
3580
3583
switch (type) {
3581
3584
case 'create':
3582
- deploymentId = yield create_1.create(client, logsUrl, description, initialStatus, environment, environmentUrl);
3583
- core.setOutput('deployment_id', deploymentId);
3585
+ try {
3586
+ deploymentId = yield create_1.create(client, logsUrl, description, status, environment, environmentUrl);
3587
+ core.setOutput('deployment_id', deploymentId);
3588
+ }
3589
+ catch (error) {
3590
+ core.error(error);
3591
+ // core.setFailed(error)
3592
+ throw error;
3593
+ }
3594
+ break;
3595
+ case 'finish':
3596
+ try {
3597
+ yield finish_1.finish(client, deploymentId, status, logsUrl, environmentUrl);
3598
+ }
3599
+ catch (error) {
3600
+ core.error(error);
3601
+ // core.setFailed(`Could not finish a deployment: ${JSON.stringify(error, null, 2)}`)
3602
+ throw error;
3603
+ }
3584
3604
break;
3585
3605
case 'delete':
3586
3606
break;
3587
3607
case 'delete-all':
3588
3608
break;
3589
- case 'status':
3590
- break;
3591
3609
}
3592
3610
});
3593
3611
}
3594
- run(); // eslint-disable-line @typescript-eslint/no-floating-promises
3612
+ exports.run = run;
3613
+ if (process.env.NODE_ENV !== 'test')
3614
+ run(); // eslint-disable-line @typescript-eslint/no-floating-promises
3615
+
3616
+
3617
+ /***/ }),
3618
+
3619
+ /***/ 209:
3620
+ /***/ (function(__unusedmodule, exports, __webpack_require__) {
3621
+
3622
+ "use strict";
3623
+
3624
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3625
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3626
+ return new (P || (P = Promise))(function (resolve, reject) {
3627
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3628
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3629
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3630
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
3631
+ });
3632
+ };
3633
+ Object.defineProperty(exports, "__esModule", { value: true });
3634
+ exports.finish = void 0;
3635
+ const github_1 = __webpack_require__(469);
3636
+ function finish(client, deploymentId, status, logUrl, environmentUrl) {
3637
+ 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 }));
3639
+ console.log(`created deployment status: ${JSON.stringify(statusResult.data, null, 2)}`);
3640
+ });
3641
+ }
3642
+ exports.finish = finish;
3595
3643
3596
3644
3597
3645
/***/ }),
@@ -8539,25 +8587,6 @@ module.exports = require("net");
8539
8587
8540
8588
"use strict";
8541
8589
8542
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8543
- if (k2 === undefined) k2 = k;
8544
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8545
- }) : (function(o, m, k, k2) {
8546
- if (k2 === undefined) k2 = k;
8547
- o[k2] = m[k];
8548
- }));
8549
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
8550
- Object.defineProperty(o, "default", { enumerable: true, value: v });
8551
- }) : function(o, v) {
8552
- o["default"] = v;
8553
- });
8554
- var __importStar = (this && this.__importStar) || function (mod) {
8555
- if (mod && mod.__esModule) return mod;
8556
- var result = {};
8557
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
8558
- __setModuleDefault(result, mod);
8559
- return result;
8560
- };
8561
8590
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8562
8591
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8563
8592
return new (P || (P = Promise))(function (resolve, reject) {
@@ -8570,7 +8599,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8570
8599
Object.defineProperty(exports, "__esModule", { value: true });
8571
8600
exports.create = void 0;
8572
8601
const github_1 = __webpack_require__(469);
8573
- const core = __importStar(__webpack_require__(470));
8574
8602
function invalidatePreviousDeployments(client, environment) {
8575
8603
return __awaiter(this, void 0, void 0, function* () {
8576
8604
const deployments = yield client.repos.listDeployments(Object.assign(Object.assign({}, github_1.context.repo), { ref: github_1.context.ref, environment }));
@@ -8593,7 +8621,6 @@ function create(client, logUrl, description, initialStatus, environment, environ
8593
8621
console.log(`created deployment: ${JSON.stringify(deployment.data, null, 2)}`);
8594
8622
const status = yield client.repos.createDeploymentStatus(Object.assign(Object.assign({}, github_1.context.repo), { deployment_id: deployment.data.id, state: initialStatus, log_url: logUrl, environment_url: environmentUrl }));
8595
8623
console.log(`created deployment status: ${JSON.stringify(status.data, null, 2)}`);
8596
- core.setOutput('deployment_id', deployment.data.id.toString());
8597
8624
return deployment.data.id.toString();
8598
8625
});
8599
8626
}
0 commit comments