Skip to content

Commit 1808f5b

Browse files
committed
Add changes for Sitecontainers deployment
1 parent 39572e3 commit 1808f5b

21 files changed

+2929
-1202
lines changed

action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ inputs:
4040
restart:
4141
description: 'Restart the app service after deployment'
4242
required: false
43-
43+
sitecontainers-config:
44+
description: 'Applies to Sitecontainers, containes a list of siteContainer specs'
45+
required: false
46+
blessed-app-sitecontainers:
47+
description: 'Applies to blessed apps with Sitecontainers'
48+
required: false
49+
default: 'false'
50+
4451
outputs:
4552
webapp-url:
4653
description: 'URL to work with your webapp'

lib/ActionInputValidator/ActionValidators/PublishProfileContainerWebAppValidator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class PublishProfileContainerWebAppValidator {
1919
(0, Validations_1.packageNotAllowed)(actionParams.packageInput);
2020
(0, Validations_1.multiContainerNotAllowed)(actionParams.multiContainerConfigFile);
2121
(0, Validations_1.startupCommandNotAllowed)(actionParams.startupCommand);
22+
(0, Validations_1.siteContainersConfigNotAllowed)(actionParams.siteContainers);
2223
(0, Validations_1.validateAppDetails)();
2324
(0, Validations_1.validateSingleContainerInputs)();
2425
});

lib/ActionInputValidator/ActionValidators/PublishProfileWebAppValidator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class PublishProfileWebAppValidator {
1919
(0, Validations_1.containerInputsNotAllowed)(actionParams.images, actionParams.multiContainerConfigFile, true);
2020
(0, Validations_1.validateAppDetails)();
2121
(0, Validations_1.startupCommandNotAllowed)(actionParams.startupCommand);
22+
(0, Validations_1.siteContainersConfigNotAllowed)(actionParams.siteContainers);
2223
yield (0, Validations_1.validatePackageInput)();
2324
});
2425
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4+
return new (P || (P = Promise))(function (resolve, reject) {
5+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8+
step((generator = generator.apply(thisArg, _arguments || [])).next());
9+
});
10+
};
11+
Object.defineProperty(exports, "__esModule", { value: true });
12+
exports.SpnWebAppSiteContainersValidator = void 0;
13+
const Validations_1 = require("../Validations");
14+
const actionparameters_1 = require("../../actionparameters");
15+
class SpnWebAppSiteContainersValidator {
16+
validate() {
17+
return __awaiter(this, void 0, void 0, function* () {
18+
const actionParams = actionparameters_1.ActionParameters.getActionParams();
19+
//packageNotAllowed(actionParams.packageInput);
20+
(0, Validations_1.validateSiteContainersInputs)();
21+
});
22+
}
23+
}
24+
exports.SpnWebAppSiteContainersValidator = SpnWebAppSiteContainersValidator;

lib/ActionInputValidator/Validations.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ exports.multiContainerNotAllowed = multiContainerNotAllowed;
4141
exports.validateSingleContainerInputs = validateSingleContainerInputs;
4242
exports.validateContainerInputs = validateContainerInputs;
4343
exports.validatePackageInput = validatePackageInput;
44+
exports.siteContainersConfigNotAllowed = siteContainersConfigNotAllowed;
45+
exports.validateSiteContainersInputs = validateSiteContainersInputs;
4446
const core = __importStar(require("@actions/core"));
4547
const packageUtility_1 = require("azure-actions-utility/packageUtility");
4648
const PublishProfile_1 = require("../Utilities/PublishProfile");
@@ -136,3 +138,16 @@ function validatePackageInput() {
136138
}
137139
});
138140
}
141+
// Error if Sitecontainers configuration is provided
142+
function siteContainersConfigNotAllowed(siteContainers) {
143+
if (!!siteContainers) {
144+
throw new Error("SiteContainers not valid input for this web app.");
145+
}
146+
}
147+
// validate Sitecontainers inputs
148+
function validateSiteContainersInputs() {
149+
const actionParams = actionparameters_1.ActionParameters.getActionParams();
150+
if (!actionParams.siteContainers || actionParams.siteContainers.length === 0) {
151+
throw new Error("Site containers not provided.");
152+
}
153+
}

lib/ActionInputValidator/ValidatorFactory.js

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
"use strict";
2+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3+
if (k2 === undefined) k2 = k;
4+
var desc = Object.getOwnPropertyDescriptor(m, k);
5+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6+
desc = { enumerable: true, get: function() { return m[k]; } };
7+
}
8+
Object.defineProperty(o, k2, desc);
9+
}) : (function(o, m, k, k2) {
10+
if (k2 === undefined) k2 = k;
11+
o[k2] = m[k];
12+
}));
13+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14+
Object.defineProperty(o, "default", { enumerable: true, value: v });
15+
}) : function(o, v) {
16+
o["default"] = v;
17+
});
18+
var __importStar = (this && this.__importStar) || function (mod) {
19+
if (mod && mod.__esModule) return mod;
20+
var result = {};
21+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22+
__setModuleDefault(result, mod);
23+
return result;
24+
};
225
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
326
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
427
return new (P || (P = Promise))(function (resolve, reject) {
@@ -14,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1437
Object.defineProperty(exports, "__esModule", { value: true });
1538
exports.ValidatorFactory = void 0;
1639
const actionparameters_1 = require("../actionparameters");
40+
const core = __importStar(require("@actions/core"));
1741
const AzureResourceFilterUtility_1 = require("azure-actions-appservice-rest/Utilities/AzureResourceFilterUtility");
1842
const BaseWebAppDeploymentProvider_1 = require("../DeploymentProvider/Providers/BaseWebAppDeploymentProvider");
1943
const PublishProfileWebAppValidator_1 = require("./ActionValidators/PublishProfileWebAppValidator");
@@ -25,37 +49,49 @@ const SpnWindowsWebAppValidator_1 = require("./ActionValidators/SpnWindowsWebApp
2549
const Validations_1 = require("./Validations");
2650
const PublishProfile_1 = require("../Utilities/PublishProfile");
2751
const RuntimeConstants_1 = __importDefault(require("../RuntimeConstants"));
52+
const SpnWebAppSiteContainersValidator_1 = require("./ActionValidators/SpnWebAppSiteContainersValidator");
2853
class ValidatorFactory {
2954
static getValidator(type) {
3055
return __awaiter(this, void 0, void 0, function* () {
3156
let actionParams = actionparameters_1.ActionParameters.getActionParams();
3257
if (type === BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE) {
33-
if (!!actionParams.images) {
58+
if (!!actionParams.blessedAppSitecontainers || !!actionParams.siteContainers) {
59+
throw new Error("publish-profile is not supported for Site Containers scenario");
60+
}
61+
else if (!!actionParams.images) {
3462
yield this.setResourceDetails(actionParams);
35-
return new PublishProfileContainerWebAppValidator_1.PublishProfileContainerWebAppValidator();
63+
return [new PublishProfileContainerWebAppValidator_1.PublishProfileContainerWebAppValidator()];
3664
}
3765
else {
38-
return new PublishProfileWebAppValidator_1.PublishProfileWebAppValidator();
66+
return [new PublishProfileWebAppValidator_1.PublishProfileWebAppValidator()];
3967
}
4068
}
4169
else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) {
4270
// app-name is required to get resource details
4371
(0, Validations_1.appNameIsRequired)(actionParams.appName);
4472
yield this.getResourceDetails(actionParams);
4573
if (!!actionParams.isLinux) {
46-
if (!!actionParams.images || !!actionParams.multiContainerConfigFile) {
47-
return new SpnLinuxContainerWebAppValidator_1.SpnLinuxContainerWebAppValidator();
74+
if (!!actionParams.blessedAppSitecontainers) {
75+
core.info("Validating site containers app details");
76+
return [new SpnWebAppSiteContainersValidator_1.SpnWebAppSiteContainersValidator(), new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator()];
77+
}
78+
else if (!!actionParams.siteContainers) {
79+
core.info("Validating site containers app details");
80+
return [new SpnWebAppSiteContainersValidator_1.SpnWebAppSiteContainersValidator()];
81+
}
82+
else if (!!actionParams.images || !!actionParams.multiContainerConfigFile) {
83+
return [new SpnLinuxContainerWebAppValidator_1.SpnLinuxContainerWebAppValidator()];
4884
}
4985
else {
50-
return new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator();
86+
return [new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator()];
5187
}
5288
}
5389
else {
5490
if (!!actionParams.images) {
55-
return new SpnWindowsContainerWebAppValidator_1.SpnWindowsContainerWebAppValidator();
91+
return [new SpnWindowsContainerWebAppValidator_1.SpnWindowsContainerWebAppValidator()];
5692
}
5793
else {
58-
return new SpnWindowsWebAppValidator_1.SpnWindowsWebAppValidator();
94+
return [new SpnWindowsWebAppValidator_1.SpnWindowsWebAppValidator()];
5995
}
6096
}
6197
}

lib/DeploymentProvider/DeploymentProviderFactory.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,29 @@ const BaseWebAppDeploymentProvider_1 = require("./Providers/BaseWebAppDeployment
66
const WebAppContainerDeployment_1 = require("./Providers/WebAppContainerDeployment");
77
const WebAppDeploymentProvider_1 = require("./Providers/WebAppDeploymentProvider");
88
const PublishProfileWebAppContainerDeploymentProvider_1 = require("./Providers/PublishProfileWebAppContainerDeploymentProvider");
9+
const WebAppSiteContainersDeploymentProvider_1 = require("./Providers/WebAppSiteContainersDeploymentProvider");
910
class DeploymentProviderFactory {
1011
static getDeploymentProvider(type) {
1112
if (type === BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE) {
1213
if (!!actionparameters_1.ActionParameters.getActionParams().images) {
13-
return new PublishProfileWebAppContainerDeploymentProvider_1.PublishProfileWebAppContainerDeploymentProvider(type);
14+
return [new PublishProfileWebAppContainerDeploymentProvider_1.PublishProfileWebAppContainerDeploymentProvider(type)];
1415
}
1516
else {
16-
return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type);
17+
return [new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type)];
1718
}
1819
}
1920
else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) {
20-
if (!!actionparameters_1.ActionParameters.getActionParams().images || (!!actionparameters_1.ActionParameters.getActionParams().isLinux && !!actionparameters_1.ActionParameters.getActionParams().multiContainerConfigFile)) {
21-
return new WebAppContainerDeployment_1.WebAppContainerDeploymentProvider(type);
21+
if (!!actionparameters_1.ActionParameters.getActionParams().blessedAppSitecontainers) {
22+
return [new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type), new WebAppSiteContainersDeploymentProvider_1.WebAppSiteContainersDeploymentProvider(type)];
23+
}
24+
else if (!!actionparameters_1.ActionParameters.getActionParams().siteContainers) {
25+
return [new WebAppSiteContainersDeploymentProvider_1.WebAppSiteContainersDeploymentProvider(type)];
26+
}
27+
else if (!!actionparameters_1.ActionParameters.getActionParams().images || (!!actionparameters_1.ActionParameters.getActionParams().isLinux && !!actionparameters_1.ActionParameters.getActionParams().multiContainerConfigFile)) {
28+
return [new WebAppContainerDeployment_1.WebAppContainerDeploymentProvider(type)];
2229
}
2330
else {
24-
return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type);
31+
return [new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type)];
2532
}
2633
}
2734
else {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"use strict";
2+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3+
if (k2 === undefined) k2 = k;
4+
var desc = Object.getOwnPropertyDescriptor(m, k);
5+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6+
desc = { enumerable: true, get: function() { return m[k]; } };
7+
}
8+
Object.defineProperty(o, k2, desc);
9+
}) : (function(o, m, k, k2) {
10+
if (k2 === undefined) k2 = k;
11+
o[k2] = m[k];
12+
}));
13+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14+
Object.defineProperty(o, "default", { enumerable: true, value: v });
15+
}) : function(o, v) {
16+
o["default"] = v;
17+
});
18+
var __importStar = (this && this.__importStar) || function (mod) {
19+
if (mod && mod.__esModule) return mod;
20+
var result = {};
21+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22+
__setModuleDefault(result, mod);
23+
return result;
24+
};
25+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27+
return new (P || (P = Promise))(function (resolve, reject) {
28+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31+
step((generator = generator.apply(thisArg, _arguments || [])).next());
32+
});
33+
};
34+
Object.defineProperty(exports, "__esModule", { value: true });
35+
exports.WebAppSiteContainersDeploymentProvider = void 0;
36+
const BaseWebAppDeploymentProvider_1 = require("./BaseWebAppDeploymentProvider");
37+
const SiteContainerDeploymentUtility_1 = require("azure-actions-appservice-rest/Utilities/SiteContainerDeploymentUtility");
38+
const core = __importStar(require("@actions/core"));
39+
class WebAppSiteContainersDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebAppDeploymentProvider {
40+
DeployWebAppStep() {
41+
return __awaiter(this, void 0, void 0, function* () {
42+
let siteContainerDeploymentUtility = new SiteContainerDeploymentUtility_1.SiteContainerDeploymentUtility(this.appService);
43+
let siteContainers = this.actionParams.siteContainers;
44+
core.info("Updating site containers");
45+
for (let i = 0; i < siteContainers.length; i++) {
46+
let siteContainer = siteContainers[i];
47+
core.info("updating site container: " + siteContainer.getName);
48+
yield siteContainerDeploymentUtility.updateSiteContainer(siteContainer);
49+
}
50+
});
51+
}
52+
}
53+
exports.WebAppSiteContainersDeploymentProvider = WebAppSiteContainersDeploymentProvider;

lib/actionparameters.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
2525
Object.defineProperty(exports, "__esModule", { value: true });
2626
exports.ActionParameters = exports.appKindMap = exports.WebAppKind = void 0;
2727
const core = __importStar(require("@actions/core"));
28+
const SiteContainer_1 = require("azure-actions-appservice-rest/Arm/SiteContainer");
2829
const github = require('@actions/github');
2930
var WebAppKind;
3031
(function (WebAppKind) {
@@ -43,6 +44,7 @@ exports.appKindMap = new Map([
4344
]);
4445
class ActionParameters {
4546
constructor(endpoint) {
47+
this._blessedAppSitecontainers = false;
4648
this._publishProfileContent = core.getInput('publish-profile');
4749
this._appName = core.getInput('app-name');
4850
this._slotName = core.getInput('slot-name');
@@ -61,6 +63,16 @@ class ActionParameters {
6163
this._targetPath = core.getInput('target-path');
6264
this._clean = core.getInput('clean');
6365
this._restart = core.getInput('restart');
66+
// Used for Sitecontainers app.
67+
const siteContainersConfigInput = core.getInput('sitecontainers-config');
68+
if (siteContainersConfigInput) {
69+
const raw = JSON.parse(siteContainersConfigInput);
70+
this._siteContainers = raw.map(SiteContainer_1.SiteContainer.fromJson);
71+
}
72+
else {
73+
this._siteContainers = null;
74+
}
75+
this._blessedAppSitecontainers = core.getInput('blessed-app-sitecontainers') === 'true';
6476
}
6577
static getActionParams(endpoint) {
6678
if (!this.actionparams) {
@@ -149,5 +161,14 @@ class ActionParameters {
149161
get restart() {
150162
return this._restart;
151163
}
164+
get siteContainers() {
165+
return this._siteContainers;
166+
}
167+
set siteContainers(siteContainers) {
168+
this._siteContainers = siteContainers;
169+
}
170+
get blessedAppSitecontainers() {
171+
return this._blessedAppSitecontainers;
172+
}
152173
}
153174
exports.ActionParameters = ActionParameters;

lib/main.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,17 @@ function main() {
6161
type = BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE;
6262
}
6363
// Validate action inputs
64-
let validator = yield ValidatorFactory_1.ValidatorFactory.getValidator(type);
65-
yield validator.validate();
66-
var deploymentProvider = DeploymentProviderFactory_1.DeploymentProviderFactory.getDeploymentProvider(type);
67-
core.debug("Predeployment Step Started");
68-
yield deploymentProvider.PreDeploymentStep();
69-
core.debug("Deployment Step Started");
70-
yield deploymentProvider.DeployWebAppStep();
64+
let validators = yield ValidatorFactory_1.ValidatorFactory.getValidator(type);
65+
for (const validator of validators) {
66+
yield validator.validate();
67+
}
68+
var deploymentProviders = DeploymentProviderFactory_1.DeploymentProviderFactory.getDeploymentProvider(type);
69+
for (const provider of deploymentProviders) {
70+
core.info("Predeployment Step Started");
71+
yield provider.PreDeploymentStep();
72+
core.info("Deployment Step Started");
73+
yield provider.DeployWebAppStep();
74+
}
7175
}
7276
catch (error) {
7377
isDeploymentSuccess = false;
@@ -81,8 +85,8 @@ function main() {
8185
}
8286
}
8387
finally {
84-
if (deploymentProvider != null) {
85-
yield deploymentProvider.UpdateDeploymentStatus(isDeploymentSuccess);
88+
if (deploymentProviders != null) {
89+
yield deploymentProviders[0].UpdateDeploymentStatus(isDeploymentSuccess);
8690
}
8791
// Reset AZURE_HTTP_USER_AGENT
8892
core.exportVariable('AZURE_HTTP_USER_AGENT', prefix);

0 commit comments

Comments
 (0)