|
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 |
| -var __importStar = (this && this.__importStar) || function (mod) { |
12 |
| - if (mod && mod.__esModule) return mod; |
13 |
| - var result = {}; |
14 |
| - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; |
15 |
| - result["default"] = mod; |
16 |
| - return result; |
17 |
| -}; |
18 |
| -Object.defineProperty(exports, "__esModule", { value: true }); |
19 |
| -const core = __importStar(require("@actions/core")); |
20 |
| -const crypto = __importStar(require("crypto")); |
21 |
| -const actionparameters_1 = require("./actionparameters"); |
22 |
| -const AuthorizerFactory_1 = require("azure-actions-webclient/AuthorizerFactory"); |
23 |
| -const BaseWebAppDeploymentProvider_1 = require("./DeploymentProvider/Providers/BaseWebAppDeploymentProvider"); |
24 |
| -const DeploymentProviderFactory_1 = require("./DeploymentProvider/DeploymentProviderFactory"); |
25 |
| -const ValidatorFactory_1 = require("./ActionInputValidator/ValidatorFactory"); |
26 |
| -var prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : ""; |
27 |
| -function main() { |
28 |
| - return __awaiter(this, void 0, void 0, function* () { |
29 |
| - let isDeploymentSuccess = true; |
30 |
| - try { |
31 |
| - // Set user agent variable |
32 |
| - let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex'); |
33 |
| - let actionName = 'DeployWebAppToAzure'; |
34 |
| - let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS_${actionName}_${usrAgentRepo}`; |
35 |
| - core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString); |
36 |
| - // Initialize action inputs |
37 |
| - let endpoint = !!core.getInput('publish-profile') ? null : yield AuthorizerFactory_1.AuthorizerFactory.getAuthorizer(); |
38 |
| - actionparameters_1.ActionParameters.getActionParams(endpoint); |
39 |
| - let type = null; |
40 |
| - if (!!endpoint) { |
41 |
| - type = BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN; |
42 |
| - } |
43 |
| - else { |
44 |
| - type = BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE; |
45 |
| - } |
46 |
| - // Validate action inputs |
47 |
| - let validator = yield ValidatorFactory_1.ValidatorFactory.getValidator(type); |
48 |
| - yield validator.validate(); |
49 |
| - var deploymentProvider = DeploymentProviderFactory_1.DeploymentProviderFactory.getDeploymentProvider(type); |
50 |
| - core.debug("Predeployment Step Started"); |
51 |
| - yield deploymentProvider.PreDeploymentStep(); |
52 |
| - core.debug("Deployment Step Started"); |
53 |
| - yield deploymentProvider.DeployWebAppStep(); |
54 |
| - } |
55 |
| - catch (error) { |
56 |
| - isDeploymentSuccess = false; |
57 |
| - core.setFailed("Deployment Failed with Error: " + error); |
58 |
| - } |
59 |
| - finally { |
60 |
| - if (deploymentProvider != null) { |
61 |
| - yield deploymentProvider.UpdateDeploymentStatus(isDeploymentSuccess); |
62 |
| - } |
63 |
| - // Reset AZURE_HTTP_USER_AGENT |
64 |
| - core.exportVariable('AZURE_HTTP_USER_AGENT', prefix); |
65 |
| - core.debug(isDeploymentSuccess ? "Deployment Succeeded" : "Deployment failed"); |
66 |
| - } |
67 |
| - }); |
68 |
| -} |
69 |
| -exports.main = main; |
70 |
| -main(); |
| 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 | +var __importStar = (this && this.__importStar) || function (mod) { |
| 12 | + if (mod && mod.__esModule) return mod; |
| 13 | + var result = {}; |
| 14 | + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; |
| 15 | + result["default"] = mod; |
| 16 | + return result; |
| 17 | +}; |
| 18 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 19 | +const core = __importStar(require("@actions/core")); |
| 20 | +const crypto = __importStar(require("crypto")); |
| 21 | +const actionparameters_1 = require("./actionparameters"); |
| 22 | +const AuthorizerFactory_1 = require("azure-actions-webclient/AuthorizerFactory"); |
| 23 | +const BaseWebAppDeploymentProvider_1 = require("./DeploymentProvider/Providers/BaseWebAppDeploymentProvider"); |
| 24 | +const DeploymentProviderFactory_1 = require("./DeploymentProvider/DeploymentProviderFactory"); |
| 25 | +const ValidatorFactory_1 = require("./ActionInputValidator/ValidatorFactory"); |
| 26 | +var prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : ""; |
| 27 | +function main() { |
| 28 | + return __awaiter(this, void 0, void 0, function* () { |
| 29 | + let isDeploymentSuccess = true; |
| 30 | + try { |
| 31 | + // Set user agent variable |
| 32 | + let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex'); |
| 33 | + let actionName = 'DeployWebAppToAzure'; |
| 34 | + let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS_${actionName}_${usrAgentRepo}`; |
| 35 | + core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString); |
| 36 | + // Initialize action inputs |
| 37 | + let endpoint = !!core.getInput('publish-profile') ? null : yield AuthorizerFactory_1.AuthorizerFactory.getAuthorizer(); |
| 38 | + actionparameters_1.ActionParameters.getActionParams(endpoint); |
| 39 | + let type = null; |
| 40 | + if (!!endpoint) { |
| 41 | + type = BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN; |
| 42 | + } |
| 43 | + else { |
| 44 | + type = BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE; |
| 45 | + } |
| 46 | + // Validate action inputs |
| 47 | + let validator = yield ValidatorFactory_1.ValidatorFactory.getValidator(type); |
| 48 | + yield validator.validate(); |
| 49 | + var deploymentProvider = DeploymentProviderFactory_1.DeploymentProviderFactory.getDeploymentProvider(type); |
| 50 | + core.debug("Predeployment Step Started"); |
| 51 | + yield deploymentProvider.PreDeploymentStep(); |
| 52 | + core.debug("Deployment Step Started"); |
| 53 | + yield deploymentProvider.DeployWebAppStep(); |
| 54 | + } |
| 55 | + catch (error) { |
| 56 | + isDeploymentSuccess = false; |
| 57 | + if (error.statusCode == 403) { |
| 58 | + core.setFailed("The deployment to your web app failed with HTTP status code 403. \ |
| 59 | + Your web app may have networking features enabled which are blocking access (such as Private Endpoints).\ |
| 60 | + For more information, please follow https://aka.ms/forbidden-deployment-error"); |
| 61 | + } |
| 62 | + else { |
| 63 | + core.setFailed("Deployment Failed, " + error); |
| 64 | + } |
| 65 | + } |
| 66 | + finally { |
| 67 | + if (deploymentProvider != null) { |
| 68 | + yield deploymentProvider.UpdateDeploymentStatus(isDeploymentSuccess); |
| 69 | + } |
| 70 | + // Reset AZURE_HTTP_USER_AGENT |
| 71 | + core.exportVariable('AZURE_HTTP_USER_AGENT', prefix); |
| 72 | + core.debug(isDeploymentSuccess ? "Deployment Succeeded" : "Deployment failed"); |
| 73 | + } |
| 74 | + }); |
| 75 | +} |
| 76 | +exports.main = main; |
| 77 | +main(); |
0 commit comments