-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathWebAppDeploymentProvider.js
More file actions
133 lines (133 loc) · 7.58 KB
/
Copy pathWebAppDeploymentProvider.js
File metadata and controls
133 lines (133 loc) · 7.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebAppDeploymentProvider = void 0;
const core = __importStar(require("@actions/core"));
const utility = __importStar(require("azure-actions-utility/utility.js"));
const zipUtility = __importStar(require("azure-actions-utility/ziputility.js"));
const packageUtility_1 = require("azure-actions-utility/packageUtility");
const BaseWebAppDeploymentProvider_1 = require("./BaseWebAppDeploymentProvider");
const AnnotationUtility_1 = require("azure-actions-appservice-rest/Utilities/AnnotationUtility");
const DeploymentMethod_1 = require("../../DeploymentMethod");
class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebAppDeploymentProvider {
DeployWebAppStep() {
return __awaiter(this, void 0, void 0, function* () {
let appPackage = this.actionParams.package;
let webPackage = appPackage.getPath();
let packageType = appPackage.getPackageType();
if (this.actionParams.deploymentMethod === DeploymentMethod_1.DeploymentMethod.ZipDeploy && packageType !== packageUtility_1.PackageType.zip) {
core.error("ZipDeploy method can only be used with zip packages. Use OneDeploy deployment method for other package types.");
}
const validTypes = ["war", "jar", "ear", "zip", "static"];
// kudu warm up
yield this.kuduServiceUtility.warmpUp();
// If provided, type paramater takes precidence over file package type
if (this.actionParams.type != null && validTypes.includes(this.actionParams.type.toLowerCase())) {
core.debug("Initiated deployment via kudu service for webapp" + this.actionParams.type + "package : " + webPackage);
}
else {
// Retains the old behavior of determining the package type from the file extension if valid type is not defined
switch (packageType) {
case packageUtility_1.PackageType.war:
core.debug("Initiated deployment via kudu service for webapp war package : " + webPackage);
this.actionParams.type = "war";
break;
case packageUtility_1.PackageType.jar:
core.debug("Initiated deployment via kudu service for webapp jar package : " + webPackage);
this.actionParams.type = "jar";
break;
case packageUtility_1.PackageType.folder:
let tempPackagePath = utility.generateTemporaryFolderOrZipPath(`${process.env.RUNNER_TEMP}`, false);
webPackage = (yield zipUtility.archiveFolder(webPackage, "", tempPackagePath));
core.debug("Compressed folder into zip " + webPackage);
core.debug("Initiated deployment via kudu service for webapp package : " + webPackage);
this.actionParams.type = "zip";
break;
case packageUtility_1.PackageType.zip:
core.debug("Initiated deployment via kudu service for webapp zip package : " + webPackage);
this.actionParams.type = "zip";
break;
default:
throw new Error('Invalid App Service package: ' + webPackage + ' or type provided: ' + this.actionParams.type);
}
}
switch (this.actionParams.deploymentMethod) {
case DeploymentMethod_1.DeploymentMethod.ZipDeploy:
core.info('Deploying using ZipDeploy method.');
this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName, commitMessage: this.actionParams.commitMessage });
break;
default:
core.info('Deploying using OneDeploy method.');
this.deploymentID = yield this.kuduServiceUtility.deployUsingOneDeploy(webPackage, { slotName: this.actionParams.slotName, commitMessage: this.actionParams.commitMessage }, this.actionParams.targetPath, this.actionParams.type, this.actionParams.clean, this.actionParams.restart);
}
// updating startup command
if (!!this.actionParams.startupCommand) {
yield this.updateStartupCommand();
}
});
}
updateStartupCommand() {
return __awaiter(this, void 0, void 0, function* () {
let currentConfig = yield this.appService.getConfiguration();
let currentStartupCommand = currentConfig.properties.appCommandLine;
let newStartupCommand = this.actionParams.startupCommand;
if (currentStartupCommand != newStartupCommand) {
yield this.appServiceUtility.updateConfigurationSettings({ appCommandLine: newStartupCommand });
}
else {
core.debug(`Skipped updating appCommandLine. Current value is: ${currentStartupCommand}`);
}
});
}
UpdateDeploymentStatus(isDeploymentSuccess) {
return __awaiter(this, void 0, void 0, function* () {
if (!!this.appService) {
yield (0, AnnotationUtility_1.addAnnotation)(this.actionParams.endpoint, this.appService, isDeploymentSuccess);
}
console.log('App Service Application URL: ' + this.applicationURL);
core.setOutput('webapp-url', this.applicationURL);
});
}
}
exports.WebAppDeploymentProvider = WebAppDeploymentProvider;