Skip to content

Commit 0f57d77

Browse files
committed
Migrate deployments to OneDeploy
1 parent 99c0cca commit 0f57d77

File tree

3 files changed

+65
-14
lines changed

3 files changed

+65
-14
lines changed

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ inputs:
2828
resource-group-name:
2929
description: 'Enter the resource group name of the web app'
3030
required: false
31+
type:
32+
description: 'Enter deployment type (JAR, WAR, EAR, ZIP, Static)'
33+
required: false
34+
target-path:
35+
description: "Target path in the web app. For ex. '/home/site/wwwroot'"
36+
required: false
37+
clean:
38+
description: 'Delete existing files target directory before deploying'
39+
required: false
40+
restart:
41+
description: 'Restart the app service after deployment'
42+
required: false
3143

3244
outputs:
3345
webapp-url:

src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { addAnnotation } from 'azure-actions-appservice-rest/Utilities/Annotatio
1010
export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
1111

1212
public async DeployWebAppStep() {
13+
var deploymentType;
1314
let appPackage: Package = this.actionParams.package;
1415
let webPackage = appPackage.getPath();
1516

@@ -20,37 +21,42 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
2021

2122
switch(packageType){
2223
case PackageType.war:
23-
core.debug("Initiated deployment via kudu service for webapp war package : "+ webPackage);
24-
var warName = utility.getFileNameFromPath(webPackage, ".war");
25-
this.deploymentID = await this.kuduServiceUtility.deployUsingWarDeploy(webPackage,
26-
{ slotName: this.actionParams.slotName , commitMessage: this.actionParams.commitMessage }, warName);
24+
core.debug("Initiated deployment via kudu service for webapp war package : "+ webPackage);
25+
deploymentType = "war";
2726
break;
2827

2928
case PackageType.jar:
3029
core.debug("Initiated deployment via kudu service for webapp jar package : "+ webPackage);
31-
let folderPath = await utility.generateTemporaryFolderForDeployment(false, webPackage, PackageType.jar);
32-
let output = await utility.archiveFolderForDeployment(false, folderPath);
33-
webPackage = output.webDeployPkg;
34-
this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName , commitMessage:this.actionParams.commitMessage });
30+
deploymentType = "jar";
3531
break;
3632

3733
case PackageType.folder:
3834
let tempPackagePath = utility.generateTemporaryFolderOrZipPath(`${process.env.RUNNER_TEMP}`, false);
3935
webPackage = await zipUtility.archiveFolder(webPackage, "", tempPackagePath) as string;
4036
core.debug("Compressed folder into zip " + webPackage);
41-
core.debug("Initiated deployment via kudu service for webapp package : "+ webPackage);
42-
this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName, commitMessage: this.actionParams.commitMessage });
37+
core.debug("Initiated deployment via kudu service for webapp package : "+ webPackage);
38+
deploymentType = "zip";
4339
break;
4440

4541
case PackageType.zip:
46-
core.debug("Initiated deployment via kudu service for webapp package : "+ webPackage);
47-
this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName , commitMessage: this.actionParams.commitMessage});
42+
core.debug("Initiated deployment via kudu service for webapp zip package : "+ webPackage);
43+
deploymentType = "zip";
4844
break;
4945

5046
default:
51-
throw new Error('Invalid App Service package or folder path provided: ' + webPackage);
47+
if (!this.actionParams.type) {
48+
throw new Error('Invalid App Service package or folder path provided: ' + webPackage);
49+
}
50+
break;
51+
}
52+
53+
if (!this.actionParams.type){
54+
this.actionParams.type = deploymentType;
5255
}
5356

57+
this.deploymentID = await this.kuduServiceUtility.deployUsingOneDeploy(webPackage, { slotName: this.actionParams.slotName, commitMessage:this.actionParams.commitMessage },
58+
this.actionParams.targetPath, this.actionParams.type, this.actionParams.clean, this.actionParams.restart);
59+
5460
// updating startup command
5561
if(!!this.actionParams.startupCommand) {
5662
await this.updateStartupCommand();

src/actionparameters.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ export class ActionParameters {
3636
private _isLinux: boolean;
3737
private _commitMessage: string;
3838

39+
// Used only for OneDeploy
40+
private _type: string;
41+
private _targetPath: string;
42+
private _clean: string;
43+
private _restart: string;
44+
45+
3946
private constructor(endpoint: IAuthorizer) {
4047
this._publishProfileContent = core.getInput('publish-profile');
4148
this._appName = core.getInput('app-name');
@@ -50,6 +57,12 @@ export class ActionParameters {
5057
*/
5158
this._commitMessage = github.context.eventName === 'push' ? github.context.payload.head_commit.message.slice(0, 1000) : "";
5259
this._endpoint = endpoint;
60+
61+
// Used only for OneDeploy
62+
this._type = core.getInput('type');
63+
this._targetPath = core.getInput('target-path');
64+
this._clean = core.getInput('clean');
65+
this._restart = core.getInput('restart');
5366
}
5467

5568
public static getActionParams(endpoint?: IAuthorizer) {
@@ -143,4 +156,24 @@ export class ActionParameters {
143156
return this._multiContainerConfigFile;
144157
}
145158

146-
}
159+
public get type()
160+
{
161+
return this._type;
162+
}
163+
164+
public set type(type:string) {
165+
this._type = type;
166+
}
167+
168+
public get targetPath(){
169+
return this._targetPath;
170+
}
171+
172+
public get clean(){
173+
return this._clean;
174+
}
175+
176+
public get restart(){
177+
return this._restart;
178+
}
179+
}

0 commit comments

Comments
 (0)