-
Notifications
You must be signed in to change notification settings - Fork 199
/
Copy pathWebAppDeploymentProvider.ts
80 lines (65 loc) · 3.92 KB
/
WebAppDeploymentProvider.ts
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
import * as core from '@actions/core';
import * as utility from 'azure-actions-utility/utility.js';
import * as zipUtility from 'azure-actions-utility/ziputility.js';
import { Package, PackageType } from "azure-actions-utility/packageUtility";
import { BaseWebAppDeploymentProvider } from './BaseWebAppDeploymentProvider';
import { addAnnotation } from 'azure-actions-appservice-rest/Utilities/AnnotationUtility';
export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
public async DeployWebAppStep() {
let appPackage: Package = this.actionParams.package;
let webPackage = appPackage.getPath();
// kudu warm up
await this.kuduServiceUtility.warmpUp();
let packageType = appPackage.getPackageType();
switch(packageType){
case PackageType.war:
core.debug("Initiated deployment via kudu service for webapp war package : "+ webPackage);
var warName = utility.getFileNameFromPath(webPackage, ".war");
this.deploymentID = await this.kuduServiceUtility.deployUsingWarDeploy(webPackage,
{ slotName: this.actionParams.slotName }, warName);
break;
case PackageType.jar:
core.debug("Initiated deployment via kudu service for webapp jar package : "+ webPackage);
let folderPath = await utility.generateTemporaryFolderForDeployment(false, webPackage, PackageType.jar);
let output = await utility.archiveFolderForDeployment(false, folderPath);
webPackage = output.webDeployPkg;
this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName });
break;
case PackageType.folder:
let tempPackagePath = utility.generateTemporaryFolderOrZipPath(`${process.env.RUNNER_TEMP}`, false);
webPackage = await zipUtility.archiveFolder(webPackage, "", tempPackagePath) as string;
core.debug("Compressed folder into zip " + webPackage);
core.debug("Initiated deployment via kudu service for webapp package : "+ webPackage);
this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName });
break;
case PackageType.zip:
core.debug("Initiated deployment via kudu service for webapp package : "+ webPackage);
this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName });
break;
default:
throw new Error('Invalid App Service package or folder path provided: ' + webPackage);
}
// updating startup command
if(!!this.actionParams.startupCommand) {
await this.updateStartupCommand();
}
}
private async updateStartupCommand() {
let currentConfig = await this.appService.getConfiguration();
let currentStartupCommand = currentConfig.properties.appCommandLine;
let newStartupCommand = this.actionParams.startupCommand;
if(currentStartupCommand != newStartupCommand) {
await this.appServiceUtility.updateConfigurationSettings({ appCommandLine: newStartupCommand});
}
else {
core.debug(`Skipped updating appCommandLine. Current value is: ${currentStartupCommand}`);
}
}
public async UpdateDeploymentStatus(isDeploymentSuccess: boolean) {
if(!!this.appService) {
await addAnnotation(this.actionParams.endpoint, this.appService, isDeploymentSuccess);
}
console.log('App Service Application URL: ' + this.applicationURL);
core.setOutput('webapp-url', this.applicationURL);
}
}