@@ -3529,18 +3529,9 @@ exports.run = void 0;
3529
3529
const core = __importStar(__webpack_require__(470));
3530
3530
const github = __importStar(__webpack_require__(469));
3531
3531
const create_1 = __webpack_require__(646);
3532
- const finish_1 = __webpack_require__(209);
3533
3532
const delete_all_1 = __webpack_require__(832);
3534
3533
const delete_1 = __webpack_require__(583);
3535
- // nullify getInput empty results
3536
- // to allow coalescence ?? operator
3537
- function getInput(name, options) {
3538
- const result = core.getInput(name, options);
3539
- if (result === '') {
3540
- return null;
3541
- }
3542
- return result;
3543
- }
3534
+ const utils_1 = __webpack_require__(611);
3544
3535
function run() {
3545
3536
var _a, _b, _c, _d, _e, _f, _g, _h;
3546
3537
return __awaiter(this, void 0, void 0, function* () {
@@ -3554,30 +3545,30 @@ function run() {
3554
3545
let deploymentId;
3555
3546
let mainBranch;
3556
3547
const { actor, ref } = github.context;
3557
- console.log('### context ###');
3548
+ console.log('### main. context ###');
3558
3549
console.log(`actor: ${actor}`);
3559
3550
console.log(`ref: ${ref}`);
3560
3551
console.log('\n');
3561
3552
try {
3562
- console.log('### inputs ###');
3563
- token = (_a = getInput('token', { required: true })) !== null && _a !== void 0 ? _a : '';
3564
- type = getInput('type', { required: true });
3553
+ console.log('### main. inputs ###');
3554
+ token = (_a = utils_1. getInput('token', { required: true })) !== null && _a !== void 0 ? _a : '';
3555
+ type = utils_1. getInput('type', { required: true });
3565
3556
console.log(`type: ${type}`);
3566
- logsUrl = (_b = getInput('logs')) !== null && _b !== void 0 ? _b : '';
3557
+ logsUrl = (_b = utils_1. getInput('logs')) !== null && _b !== void 0 ? _b : '';
3567
3558
console.log(`logs: ${logsUrl}`);
3568
- description = (_c = getInput('description')) !== null && _c !== void 0 ? _c : `deployed by ${actor}`;
3559
+ description = (_c = utils_1. getInput('description')) !== null && _c !== void 0 ? _c : `deployed by ${actor}`;
3569
3560
console.log(`description: ${description}`);
3570
- status = ((_d = getInput('status')) !== null && _d !== void 0 ? _d : 'in_progress');
3561
+ status = ((_d = utils_1. getInput('status')) !== null && _d !== void 0 ? _d : 'in_progress');
3571
3562
console.log(`status: ${status}`);
3572
3563
// default to branch name w/o `deploy-` prefix
3573
- environment = (_e = getInput('environment')) !== null && _e !== void 0 ? _e : ref.replace('refs/heads/', '').replace(/^deploy-/, '');
3564
+ environment = (_e = utils_1. getInput('environment')) !== null && _e !== void 0 ? _e : ref.replace('refs/heads/', '').replace(/^deploy-/, '');
3574
3565
console.log(`environment: ${environment}`);
3575
- environmentUrl = (_f = getInput('environment_url')) !== null && _f !== void 0 ? _f : '';
3566
+ environmentUrl = (_f = utils_1. getInput('environment_url')) !== null && _f !== void 0 ? _f : '';
3576
3567
console.log(`environmentUrl: ${environmentUrl}`);
3577
- mainBranch = (_g = getInput('main_branch')) !== null && _g !== void 0 ? _g : 'master';
3568
+ mainBranch = (_g = utils_1. getInput('main_branch')) !== null && _g !== void 0 ? _g : 'master';
3578
3569
console.log(`main branch: ${mainBranch}`);
3579
- const shouldRequireDeploymentId = type === 'finish' || type === ' delete';
3580
- deploymentId = (_h = getInput('deployment_id' , { required: shouldRequireDeploymentId })) !== null && _h !== void 0 ? _h : '0';
3570
+ const shouldRequireDeploymentId = type === 'delete';
3571
+ deploymentId = (_h = utils_1. getInput(utils_1.DEPLOYMENT_ID_STATE_NAME , { required: shouldRequireDeploymentId })) !== null && _h !== void 0 ? _h : '0';
3581
3572
console.log(`deploymentId: ${deploymentId}`);
3582
3573
}
3583
3574
catch (error) {
@@ -3592,25 +3583,16 @@ function run() {
3592
3583
case 'create':
3593
3584
try {
3594
3585
deploymentId = yield create_1.create(client, logsUrl, description, status, environment, environmentUrl, mainBranch);
3595
- console.log(`setOutput::deployment_id: ${deploymentId}`);
3596
- core.setOutput('deployment_id', deploymentId);
3586
+ console.log(`saveState::${utils_1.DEPLOYMENT_ID_STATE_NAME}: ${deploymentId}`);
3587
+ core.saveState(utils_1.DEPLOYMENT_ID_STATE_NAME, deploymentId); // for internal use
3588
+ core.setOutput(utils_1.DEPLOYMENT_ID_STATE_NAME, deploymentId); // keep that output for external dependencies
3597
3589
}
3598
3590
catch (error) {
3599
3591
core.error(error);
3600
3592
core.setFailed(`Create deployment failed: ${JSON.stringify(error, null, 2)}`);
3601
3593
throw error;
3602
3594
}
3603
3595
break;
3604
- case 'finish':
3605
- try {
3606
- yield finish_1.finish(client, Number(deploymentId), status);
3607
- }
3608
- catch (error) {
3609
- core.error(error);
3610
- core.setFailed(`Finish deployment failed: ${JSON.stringify(error, null, 2)}`);
3611
- throw error;
3612
- }
3613
- break;
3614
3596
case 'delete':
3615
3597
try {
3616
3598
yield delete_1.deleteDeployment(client, Number(deploymentId));
@@ -3639,37 +3621,6 @@ if (process.env.NODE_ENV !== 'test')
3639
3621
run(); // eslint-disable-line @typescript-eslint/no-floating-promises
3640
3622
3641
3623
3642
- /***/ }),
3643
-
3644
- /***/ 209:
3645
- /***/ (function(__unusedmodule, exports, __webpack_require__) {
3646
-
3647
- "use strict";
3648
-
3649
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3650
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3651
- return new (P || (P = Promise))(function (resolve, reject) {
3652
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3653
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3654
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3655
- step((generator = generator.apply(thisArg, _arguments || [])).next());
3656
- });
3657
- };
3658
- Object.defineProperty(exports, "__esModule", { value: true });
3659
- exports.finish = void 0;
3660
- const github_1 = __webpack_require__(469);
3661
- function finish(client, deploymentId, status) {
3662
- return __awaiter(this, void 0, void 0, function* () {
3663
- const statuses = yield client.repos.listDeploymentStatuses(Object.assign(Object.assign({}, github_1.context.repo), { deployment_id: deploymentId }));
3664
- const lastStatus = statuses.data.sort((a, b) => a.id - b.id).slice(-1)[0];
3665
- console.log(`last status for deployment_id '${deploymentId}': ${JSON.stringify(lastStatus, null, 2)}`);
3666
- const statusResult = yield client.repos.createDeploymentStatus(Object.assign(Object.assign({}, github_1.context.repo), { deployment_id: deploymentId, state: status, environment_url: lastStatus.environment_url, log_url: lastStatus.log_url }));
3667
- console.log(`created deployment status: ${JSON.stringify(statusResult.data, null, 2)}`);
3668
- });
3669
- }
3670
- exports.finish = finish;
3671
-
3672
-
3673
3624
/***/ }),
3674
3625
3675
3626
/***/ 211:
@@ -8544,6 +8495,48 @@ exports.deleteDeployment = deleteDeployment;
8544
8495
8545
8496
module.exports = require("http");
8546
8497
8498
+ /***/ }),
8499
+
8500
+ /***/ 611:
8501
+ /***/ (function(__unusedmodule, exports, __webpack_require__) {
8502
+
8503
+ "use strict";
8504
+
8505
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8506
+ if (k2 === undefined) k2 = k;
8507
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8508
+ }) : (function(o, m, k, k2) {
8509
+ if (k2 === undefined) k2 = k;
8510
+ o[k2] = m[k];
8511
+ }));
8512
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
8513
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
8514
+ }) : function(o, v) {
8515
+ o["default"] = v;
8516
+ });
8517
+ var __importStar = (this && this.__importStar) || function (mod) {
8518
+ if (mod && mod.__esModule) return mod;
8519
+ var result = {};
8520
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
8521
+ __setModuleDefault(result, mod);
8522
+ return result;
8523
+ };
8524
+ Object.defineProperty(exports, "__esModule", { value: true });
8525
+ exports.getInput = exports.DEPLOYMENT_ID_STATE_NAME = void 0;
8526
+ const core = __importStar(__webpack_require__(470));
8527
+ exports.DEPLOYMENT_ID_STATE_NAME = 'deployment_id';
8528
+ // nullify getInput empty results
8529
+ // to allow coalescence ?? operator
8530
+ function getInput(name, options) {
8531
+ const result = core.getInput(name, options);
8532
+ if (result === '') {
8533
+ return null;
8534
+ }
8535
+ return result;
8536
+ }
8537
+ exports.getInput = getInput;
8538
+
8539
+
8547
8540
/***/ }),
8548
8541
8549
8542
/***/ 614:
0 commit comments