diff --git a/.github/ISSUE_TEMPLATE/bug-report---feature-request.md b/.github/ISSUE_TEMPLATE/bug-report---feature-request.md new file mode 100644 index 000000000..214d54b64 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report---feature-request.md @@ -0,0 +1,10 @@ +--- +name: Bug Report / Feature Request +about: Create a report to help us improve +title: '' +labels: need-to-triage +assignees: '' + +--- + + diff --git a/.github/workflows/defaultLabels.yml b/.github/workflows/defaultLabels.yml new file mode 100644 index 000000000..a4c736840 --- /dev/null +++ b/.github/workflows/defaultLabels.yml @@ -0,0 +1,35 @@ +name: setting-default-labels + +# Controls when the action will run. +on: + schedule: + - cron: "0 0/3 * * *" + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - uses: actions/stale@v3 + name: Setting issue as idle + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'This issue is idle because it has been open for 14 days with no activity.' + stale-issue-label: 'idle' + days-before-stale: 14 + days-before-close: -1 + operations-per-run: 100 + exempt-issue-labels: 'backlog' + + - uses: actions/stale@v3 + name: Setting PR as idle + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-pr-message: 'This PR is idle because it has been open for 14 days with no activity.' + stale-pr-label: 'idle' + days-before-stale: 14 + days-before-close: -1 + operations-per-run: 100 diff --git a/README.md b/README.md index 002002564..57cda5933 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ NOTE: you must have write permissions to the repository in question. If you're u * Authenticate using [Azure Web App Publish Profile](https://github.com/projectkudu/kudu/wiki/Deployment-credentials#site-credentials-aka-publish-profile-credentials) or using the [Azure Login Action](https://github.com/Azure/login). Examples of both are given later in this article. The action supports using publish profile for [Azure Web Apps](https://azure.microsoft.com/services/app-service/web/) (both Windows and Linux) and [Azure Web Apps for Containers](https://azure.microsoft.com/services/app-service/containers/) (Linux only). + + **Note: As of October 2020, Linux web apps will need the app setting `WEBSITE_WEBDEPLOY_USE_SCM` set to `true` before downloading the publish profile from the portal. This requirement will be removed in the future.** The action does not support multi-container scenario with publish profile. @@ -41,6 +43,7 @@ Note: Workflow samples with sample application code and deployment procedure for For example, if You want to deploy a Java WAR based app, You can follow the link https://github.com/Azure-Samples/Java-application-petstore-ee7 in the sample workflow templates. +0. Review the pre-requisites outlined in the ["Dependencies on Other Github Actions"](https://github.com/Azure/webapps-deploy#dependencies-on-other-github-actions) section above. 1. Create a web app in Azure using app service. Follow the tutorial [Azure Web Apps Quickstart](https://docs.microsoft.com/azure/app-service/overview#next-steps). 2. Pick a template from the following table depends on your Azure web app **runtime** and place the template to `.github/workflows/` in your project repository. 3. Change `app-name` to your Web app name created in the first step. @@ -53,6 +56,7 @@ For example, if You want to deploy a Java WAR based app, You can follow the link | Java | [java_jar.yml](https://github.com/Azure/actions-workflow-samples/tree/master/AppService/java-jar-webapp-on-azure.yml) | | Java | [java_war.yml](https://github.com/Azure/actions-workflow-samples/tree/master/AppService/java-war-webapp-on-azure.yml) | | Python | [python.yml](https://github.com/Azure/actions-workflow-samples/tree/master/AppService/python-webapp-on-azure.yml) | +| PHP | [php.yml](https://github.com/Azure/actions-workflow-samples/blob/master/AppService/php-webapp-on-azure.yml) | DOCKER | [docker.yml](https://github.com/Azure/actions-workflow-samples/blob/master/AppService/docker-webapp-container-on-azure.yml) | ### Sample workflow to build and deploy a Node.js Web app to Azure using publish profile @@ -119,6 +123,7 @@ jobs: publish-profile: ${{ secrets.azureWebAppPublishProfile }} images: 'contoso.azurecr.io/nodejssampleapp:${{ github.sha }}' ``` +Webapps deploy Actions is supported for the Azure public cloud as well as Azure government clouds ('AzureUSGovernment' or 'AzureChinaCloud') and Azure Stack ('AzureStack') Hub. Before running this action, login to the respective Azure Cloud using [Azure Login](https://github.com/Azure/login) by setting appropriate value for the `environment` parameter. #### Configure deployment credentials: @@ -128,6 +133,7 @@ The above example uses app-level credentials i.e., publish profile file for depl Follow the steps to configure the secret: +* **Note: As of October 2020, Linux web apps will need the app setting `WEBSITE_WEBDEPLOY_USE_SCM` set to `true` before continuing with next step of downloading the publish profile. This requirement will be removed in the future.** * Download the publish profile for the WebApp from the portal (Get Publish profile option) * While deploying to slot, download the publish profile for slot. Also specify the `slot-name` field with the name of the slot. * Define a new secret under your repository settings, Add secret menu diff --git a/lib/ActionInputValidator/ActionValidators/IValidator.js b/lib/ActionInputValidator/ActionValidators/IValidator.js index ce03781e2..c8ad2e549 100644 --- a/lib/ActionInputValidator/ActionValidators/IValidator.js +++ b/lib/ActionInputValidator/ActionValidators/IValidator.js @@ -1,2 +1,2 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/ActionInputValidator/ActionValidators/PublishProfileWebAppValidator.js b/lib/ActionInputValidator/ActionValidators/PublishProfileWebAppValidator.js index 298ff7349..90e049958 100644 --- a/lib/ActionInputValidator/ActionValidators/PublishProfileWebAppValidator.js +++ b/lib/ActionInputValidator/ActionValidators/PublishProfileWebAppValidator.js @@ -1,25 +1,25 @@ -"use strict"; -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 }); -const Validations_1 = require("../Validations"); -const actionparameters_1 = require("../../actionparameters"); -class PublishProfileWebAppValidator { - validate() { - return __awaiter(this, void 0, void 0, function* () { - let actionParams = actionparameters_1.ActionParameters.getActionParams(); - Validations_1.containerInputsNotAllowed(actionParams.images, actionParams.multiContainerConfigFile, true); - Validations_1.validateAppDetails(); - Validations_1.startupCommandNotAllowed(actionParams.startupCommand); - yield Validations_1.validatePackageInput(); - }); - } -} -exports.PublishProfileWebAppValidator = PublishProfileWebAppValidator; +"use strict"; +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 }); +const Validations_1 = require("../Validations"); +const actionparameters_1 = require("../../actionparameters"); +class PublishProfileWebAppValidator { + validate() { + return __awaiter(this, void 0, void 0, function* () { + let actionParams = actionparameters_1.ActionParameters.getActionParams(); + Validations_1.containerInputsNotAllowed(actionParams.images, actionParams.multiContainerConfigFile, true); + Validations_1.validateAppDetails(); + Validations_1.startupCommandNotAllowed(actionParams.startupCommand); + yield Validations_1.validatePackageInput(); + }); + } +} +exports.PublishProfileWebAppValidator = PublishProfileWebAppValidator; diff --git a/lib/ActionInputValidator/ActionValidators/SpnLinuxContainerWebAppValidator.js b/lib/ActionInputValidator/ActionValidators/SpnLinuxContainerWebAppValidator.js index 2b49b891d..999377722 100644 --- a/lib/ActionInputValidator/ActionValidators/SpnLinuxContainerWebAppValidator.js +++ b/lib/ActionInputValidator/ActionValidators/SpnLinuxContainerWebAppValidator.js @@ -1,12 +1,12 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const Validations_1 = require("../Validations"); -const actionparameters_1 = require("../../actionparameters"); -class SpnLinuxContainerWebAppValidator { - validate() { - let actionParams = actionparameters_1.ActionParameters.getActionParams(); - Validations_1.packageNotAllowed(actionParams.packageInput); - Validations_1.validateContainerInputs(); - } -} -exports.SpnLinuxContainerWebAppValidator = SpnLinuxContainerWebAppValidator; +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Validations_1 = require("../Validations"); +const actionparameters_1 = require("../../actionparameters"); +class SpnLinuxContainerWebAppValidator { + validate() { + let actionParams = actionparameters_1.ActionParameters.getActionParams(); + Validations_1.packageNotAllowed(actionParams.packageInput); + Validations_1.validateContainerInputs(); + } +} +exports.SpnLinuxContainerWebAppValidator = SpnLinuxContainerWebAppValidator; diff --git a/lib/ActionInputValidator/ActionValidators/SpnLinuxWebAppValidator.js b/lib/ActionInputValidator/ActionValidators/SpnLinuxWebAppValidator.js index dc5e03655..7f82fa96e 100644 --- a/lib/ActionInputValidator/ActionValidators/SpnLinuxWebAppValidator.js +++ b/lib/ActionInputValidator/ActionValidators/SpnLinuxWebAppValidator.js @@ -1,23 +1,23 @@ -"use strict"; -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 }); -const Validations_1 = require("../Validations"); -const actionparameters_1 = require("../../actionparameters"); -class SpnLinuxWebAppValidator { - validate() { - return __awaiter(this, void 0, void 0, function* () { - let actionParams = actionparameters_1.ActionParameters.getActionParams(); - Validations_1.containerInputsNotAllowed(actionParams.images, actionParams.multiContainerConfigFile); - yield Validations_1.validatePackageInput(); - }); - } -} -exports.SpnLinuxWebAppValidator = SpnLinuxWebAppValidator; +"use strict"; +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 }); +const Validations_1 = require("../Validations"); +const actionparameters_1 = require("../../actionparameters"); +class SpnLinuxWebAppValidator { + validate() { + return __awaiter(this, void 0, void 0, function* () { + let actionParams = actionparameters_1.ActionParameters.getActionParams(); + Validations_1.containerInputsNotAllowed(actionParams.images, actionParams.multiContainerConfigFile); + yield Validations_1.validatePackageInput(); + }); + } +} +exports.SpnLinuxWebAppValidator = SpnLinuxWebAppValidator; diff --git a/lib/ActionInputValidator/ActionValidators/SpnWindowsContainerWebAppValidator.js b/lib/ActionInputValidator/ActionValidators/SpnWindowsContainerWebAppValidator.js index 612763247..3e2d25d1a 100644 --- a/lib/ActionInputValidator/ActionValidators/SpnWindowsContainerWebAppValidator.js +++ b/lib/ActionInputValidator/ActionValidators/SpnWindowsContainerWebAppValidator.js @@ -1,14 +1,14 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const Validations_1 = require("../Validations"); -const actionparameters_1 = require("../../actionparameters"); -class SpnWindowsContainerWebAppValidator { - validate() { - let actionParams = actionparameters_1.ActionParameters.getActionParams(); - Validations_1.packageNotAllowed(actionParams.packageInput); - Validations_1.startupCommandNotAllowed(actionParams.startupCommand); - Validations_1.multiContainerNotAllowed(actionParams.multiContainerConfigFile); - Validations_1.validateContainerInputs(); - } -} -exports.SpnWindowsContainerWebAppValidator = SpnWindowsContainerWebAppValidator; +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Validations_1 = require("../Validations"); +const actionparameters_1 = require("../../actionparameters"); +class SpnWindowsContainerWebAppValidator { + validate() { + let actionParams = actionparameters_1.ActionParameters.getActionParams(); + Validations_1.packageNotAllowed(actionParams.packageInput); + Validations_1.startupCommandNotAllowed(actionParams.startupCommand); + Validations_1.multiContainerNotAllowed(actionParams.multiContainerConfigFile); + Validations_1.validateContainerInputs(); + } +} +exports.SpnWindowsContainerWebAppValidator = SpnWindowsContainerWebAppValidator; diff --git a/lib/ActionInputValidator/ActionValidators/SpnWindowsWebAppValidator.js b/lib/ActionInputValidator/ActionValidators/SpnWindowsWebAppValidator.js index 151576ccc..6c1bd3a4e 100644 --- a/lib/ActionInputValidator/ActionValidators/SpnWindowsWebAppValidator.js +++ b/lib/ActionInputValidator/ActionValidators/SpnWindowsWebAppValidator.js @@ -1,24 +1,24 @@ -"use strict"; -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 }); -const Validations_1 = require("../Validations"); -const actionparameters_1 = require("../../actionparameters"); -class SpnWindowsWebAppValidator { - validate() { - return __awaiter(this, void 0, void 0, function* () { - let actionParams = actionparameters_1.ActionParameters.getActionParams(); - Validations_1.containerInputsNotAllowed(actionParams.images, actionParams.multiContainerConfigFile); - Validations_1.startupCommandNotAllowed(actionParams.startupCommand); - yield Validations_1.validatePackageInput(); - }); - } -} -exports.SpnWindowsWebAppValidator = SpnWindowsWebAppValidator; +"use strict"; +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 }); +const Validations_1 = require("../Validations"); +const actionparameters_1 = require("../../actionparameters"); +class SpnWindowsWebAppValidator { + validate() { + return __awaiter(this, void 0, void 0, function* () { + let actionParams = actionparameters_1.ActionParameters.getActionParams(); + Validations_1.containerInputsNotAllowed(actionParams.images, actionParams.multiContainerConfigFile); + Validations_1.startupCommandNotAllowed(actionParams.startupCommand); + yield Validations_1.validatePackageInput(); + }); + } +} +exports.SpnWindowsWebAppValidator = SpnWindowsWebAppValidator; diff --git a/lib/ActionInputValidator/Validations.js b/lib/ActionInputValidator/Validations.js index 58ca8f711..580ea3002 100644 --- a/lib/ActionInputValidator/Validations.js +++ b/lib/ActionInputValidator/Validations.js @@ -1,138 +1,138 @@ -"use strict"; -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()); - }); -}; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(require("@actions/core")); -const packageUtility_1 = require("azure-actions-utility/packageUtility"); -const PublishProfile_1 = require("../Utilities/PublishProfile"); -const RuntimeConstants_1 = __importDefault(require("../RuntimeConstants")); -const actionparameters_1 = require("../actionparameters"); -const fs = require("fs"); -// Error is app-name is not provided -function appNameIsRequired(appname) { - if (!appname) { - throw new Error("app-name is a required input."); - } -} -exports.appNameIsRequired = appNameIsRequired; -// Error if image info is provided -function containerInputsNotAllowed(images, configFile, isPublishProfile = false) { - if (!!images || !!configFile) { - throw new Error(`This is not a container web app. Please remove inputs like images and configuration-file which are only relevant for container deployment.`); - } -} -exports.containerInputsNotAllowed = containerInputsNotAllowed; -// Cross-validate provided app name and slot is same as that in publish profile -function validateAppDetails() { - let actionParams = actionparameters_1.ActionParameters.getActionParams(); - if (!!actionParams.appName || (!!actionParams.slotName && actionParams.slotName !== 'production')) { - let creds = PublishProfile_1.PublishProfile.getPublishProfile(actionParams.publishProfileContent).creds; - //for kubeapps in publishsettings file username doesn't start with $, for all other apps it starts with $ - let splitUsername = creds.username.startsWith("$") ? creds.username.toUpperCase().substring(1).split("__") : creds.username.toUpperCase().split("__"); - let appNameMatch = !actionParams.appName || actionParams.appName.toUpperCase() === splitUsername[0]; - let slotNameMatch = actionParams.slotName === 'production' || actionParams.slotName.toUpperCase() === splitUsername[1]; - if (!appNameMatch || !slotNameMatch) { - throw new Error("Publish profile is invalid for app-name and slot-name provided. Provide correct publish profile credentials for app."); - } - } -} -exports.validateAppDetails = validateAppDetails; -// Error is startup command is provided -function startupCommandNotAllowed(startupCommand) { - if (!!startupCommand) { - throw new Error("startup-command is not a valid input for Windows web app or with publish-profile auth scheme."); - } -} -exports.startupCommandNotAllowed = startupCommandNotAllowed; -// Error if package input is provided -function packageNotAllowed(apppackage) { - if (!!apppackage && apppackage !== '.') { - throw new Error("package is not a valid input for container web app."); - } -} -exports.packageNotAllowed = packageNotAllowed; -// Error if multi container config file is provided -function multiContainerNotAllowed(configFile) { - if (!!configFile) { - throw new Error("Multi container support is not available for windows containerized web app."); - } -} -exports.multiContainerNotAllowed = multiContainerNotAllowed; -// Error if image name is not provided -function validateSingleContainerInputs() { - const actionParams = actionparameters_1.ActionParameters.getActionParams(); - if (!actionParams.images) { - throw new Error("Image name not provided for container. Provide a valid image name"); - } -} -exports.validateSingleContainerInputs = validateSingleContainerInputs; -// Validate container inputs -function validateContainerInputs() { - let actionParams = actionparameters_1.ActionParameters.getActionParams(); - actionParams.isMultiContainer = false; - if (!!actionParams.multiContainerConfigFile && packageUtility_1.exist(actionParams.multiContainerConfigFile)) { - let stats = fs.statSync(actionParams.multiContainerConfigFile); - if (!stats.isFile()) { - throw new Error("Docker-compose file path is incorrect."); - } - else { - actionParams.isMultiContainer = true; - core.debug("Is multi-container app"); - } - if (!!actionParams.images) { - console.log("Multi-container deployment with the transformation of Docker-Compose file."); - } - else { - console.log("Multi-container deployment without transformation of Docker-Compose file."); - } - } - else if (!actionParams.images) { - throw new Error("For single-container, just specify a valid image name. For multi-container specifying a Docker-Compose file is mandatory and specifying image names is optional. Provide image names if the tags in Docker-Compose file need to be substituted."); - } - else if (actionParams.images.split("\n").length > 1) { - throw new Error("Multiple images indicate multi-container deployment type, but Docker-compose file is absent."); - } -} -exports.validateContainerInputs = validateContainerInputs; -// validate package input -function validatePackageInput() { - return __awaiter(this, void 0, void 0, function* () { - let actionParams = actionparameters_1.ActionParameters.getActionParams(); - actionParams.package = new packageUtility_1.Package(actionParams.packageInput); - // msbuild package deployment is not supported - let isMSBuildPackage = yield actionParams.package.isMSBuildPackage(); - if (isMSBuildPackage) { - throw new Error(`Deployment of msBuild generated package is not supported. Please change package format.`); - } - }); -} -exports.validatePackageInput = validatePackageInput; -// windows container app not allowed for publish profile auth scheme -function windowsContainerAppNotAllowedForPublishProfile() { - return __awaiter(this, void 0, void 0, function* () { - const actionParams = actionparameters_1.ActionParameters.getActionParams(); - const publishProfile = PublishProfile_1.PublishProfile.getPublishProfile(actionParams.publishProfileContent); - const appOS = yield publishProfile.getAppOS(); - if (appOS.includes(RuntimeConstants_1.default.Windows) || appOS.includes(RuntimeConstants_1.default.Windows.toLowerCase())) { - throw new Error("Publish profile auth scheme is not supported for Windows container Apps."); - } - }); -} -exports.windowsContainerAppNotAllowedForPublishProfile = windowsContainerAppNotAllowedForPublishProfile; +"use strict"; +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()); + }); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(require("@actions/core")); +const packageUtility_1 = require("azure-actions-utility/packageUtility"); +const PublishProfile_1 = require("../Utilities/PublishProfile"); +const RuntimeConstants_1 = __importDefault(require("../RuntimeConstants")); +const actionparameters_1 = require("../actionparameters"); +const fs = require("fs"); +// Error is app-name is not provided +function appNameIsRequired(appname) { + if (!appname) { + throw new Error("app-name is a required input."); + } +} +exports.appNameIsRequired = appNameIsRequired; +// Error if image info is provided +function containerInputsNotAllowed(images, configFile, isPublishProfile = false) { + if (!!images || !!configFile) { + throw new Error(`This is not a container web app. Please remove inputs like images and configuration-file which are only relevant for container deployment.`); + } +} +exports.containerInputsNotAllowed = containerInputsNotAllowed; +// Cross-validate provided app name and slot is same as that in publish profile +function validateAppDetails() { + let actionParams = actionparameters_1.ActionParameters.getActionParams(); + if (!!actionParams.appName || (!!actionParams.slotName && actionParams.slotName !== 'production')) { + let creds = PublishProfile_1.PublishProfile.getPublishProfile(actionParams.publishProfileContent).creds; + //for kubeapps in publishsettings file username doesn't start with $, for all other apps it starts with $ + let splitUsername = creds.username.startsWith("$") ? creds.username.toUpperCase().substring(1).split("__") : creds.username.toUpperCase().split("__"); + let appNameMatch = !actionParams.appName || actionParams.appName.toUpperCase() === splitUsername[0]; + let slotNameMatch = actionParams.slotName === 'production' || actionParams.slotName.toUpperCase() === splitUsername[1]; + if (!appNameMatch || !slotNameMatch) { + throw new Error("Publish profile is invalid for app-name and slot-name provided. Provide correct publish profile credentials for app."); + } + } +} +exports.validateAppDetails = validateAppDetails; +// Error is startup command is provided +function startupCommandNotAllowed(startupCommand) { + if (!!startupCommand) { + throw new Error("startup-command is not a valid input for Windows web app or with publish-profile auth scheme."); + } +} +exports.startupCommandNotAllowed = startupCommandNotAllowed; +// Error if package input is provided +function packageNotAllowed(apppackage) { + if (!!apppackage && apppackage !== '.') { + throw new Error("package is not a valid input for container web app."); + } +} +exports.packageNotAllowed = packageNotAllowed; +// Error if multi container config file is provided +function multiContainerNotAllowed(configFile) { + if (!!configFile) { + throw new Error("Multi container support is not available for windows containerized web app."); + } +} +exports.multiContainerNotAllowed = multiContainerNotAllowed; +// Error if image name is not provided +function validateSingleContainerInputs() { + const actionParams = actionparameters_1.ActionParameters.getActionParams(); + if (!actionParams.images) { + throw new Error("Image name not provided for container. Provide a valid image name"); + } +} +exports.validateSingleContainerInputs = validateSingleContainerInputs; +// Validate container inputs +function validateContainerInputs() { + let actionParams = actionparameters_1.ActionParameters.getActionParams(); + actionParams.isMultiContainer = false; + if (!!actionParams.multiContainerConfigFile && packageUtility_1.exist(actionParams.multiContainerConfigFile)) { + let stats = fs.statSync(actionParams.multiContainerConfigFile); + if (!stats.isFile()) { + throw new Error("Docker-compose file path is incorrect."); + } + else { + actionParams.isMultiContainer = true; + core.debug("Is multi-container app"); + } + if (!!actionParams.images) { + console.log("Multi-container deployment with the transformation of Docker-Compose file."); + } + else { + console.log("Multi-container deployment without transformation of Docker-Compose file."); + } + } + else if (!actionParams.images) { + throw new Error("For single-container, just specify a valid image name. For multi-container specifying a Docker-Compose file is mandatory and specifying image names is optional. Provide image names if the tags in Docker-Compose file need to be substituted."); + } + else if (actionParams.images.split("\n").length > 1) { + throw new Error("Multiple images indicate multi-container deployment type, but Docker-compose file is absent."); + } +} +exports.validateContainerInputs = validateContainerInputs; +// validate package input +function validatePackageInput() { + return __awaiter(this, void 0, void 0, function* () { + let actionParams = actionparameters_1.ActionParameters.getActionParams(); + actionParams.package = new packageUtility_1.Package(actionParams.packageInput); + // msbuild package deployment is not supported + let isMSBuildPackage = yield actionParams.package.isMSBuildPackage(); + if (isMSBuildPackage) { + throw new Error(`Deployment of msBuild generated package is not supported. Please change package format.`); + } + }); +} +exports.validatePackageInput = validatePackageInput; +// windows container app not allowed for publish profile auth scheme +function windowsContainerAppNotAllowedForPublishProfile() { + return __awaiter(this, void 0, void 0, function* () { + const actionParams = actionparameters_1.ActionParameters.getActionParams(); + const publishProfile = PublishProfile_1.PublishProfile.getPublishProfile(actionParams.publishProfileContent); + const appOS = yield publishProfile.getAppOS(); + if (appOS.includes(RuntimeConstants_1.default.Windows) || appOS.includes(RuntimeConstants_1.default.Windows.toLowerCase())) { + throw new Error("Publish profile auth scheme is not supported for Windows container Apps."); + } + }); +} +exports.windowsContainerAppNotAllowedForPublishProfile = windowsContainerAppNotAllowedForPublishProfile; diff --git a/lib/ActionInputValidator/ValidatorFactory.js b/lib/ActionInputValidator/ValidatorFactory.js index 93f570515..8a196e353 100644 --- a/lib/ActionInputValidator/ValidatorFactory.js +++ b/lib/ActionInputValidator/ValidatorFactory.js @@ -1,84 +1,85 @@ -"use strict"; -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()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const actionparameters_1 = require("../actionparameters"); -const AzureResourceFilterUtility_1 = require("azure-actions-appservice-rest/Utilities/AzureResourceFilterUtility"); -const BaseWebAppDeploymentProvider_1 = require("../DeploymentProvider/Providers/BaseWebAppDeploymentProvider"); -const PublishProfileWebAppValidator_1 = require("./ActionValidators/PublishProfileWebAppValidator"); -const PublishProfileContainerWebAppValidator_1 = require("./ActionValidators/PublishProfileContainerWebAppValidator"); -const SpnLinuxContainerWebAppValidator_1 = require("./ActionValidators/SpnLinuxContainerWebAppValidator"); -const SpnLinuxWebAppValidator_1 = require("./ActionValidators/SpnLinuxWebAppValidator"); -const SpnWindowsContainerWebAppValidator_1 = require("./ActionValidators/SpnWindowsContainerWebAppValidator"); -const SpnWindowsWebAppValidator_1 = require("./ActionValidators/SpnWindowsWebAppValidator"); -const Validations_1 = require("./Validations"); -const PublishProfile_1 = require("../Utilities/PublishProfile"); -const RuntimeConstants_1 = __importDefault(require("../RuntimeConstants")); -class ValidatorFactory { - static getValidator(type) { - return __awaiter(this, void 0, void 0, function* () { - let actionParams = actionparameters_1.ActionParameters.getActionParams(); - if (type === BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE) { - if (!!actionParams.images) { - yield this.setResourceDetails(actionParams); - return new PublishProfileContainerWebAppValidator_1.PublishProfileContainerWebAppValidator(); - } - else { - return new PublishProfileWebAppValidator_1.PublishProfileWebAppValidator(); - } - } - else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) { - // app-name is required to get resource details - Validations_1.appNameIsRequired(actionParams.appName); - yield this.getResourceDetails(actionParams); - if (!!actionParams.isLinux) { - if (!!actionParams.images) { - return new SpnLinuxContainerWebAppValidator_1.SpnLinuxContainerWebAppValidator(); - } - else { - return new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator(); - } - } - else { - if (!!actionParams.images) { - return new SpnWindowsContainerWebAppValidator_1.SpnWindowsContainerWebAppValidator(); - } - else { - return new SpnWindowsWebAppValidator_1.SpnWindowsWebAppValidator(); - } - } - } - else { - throw new Error("Valid credentails are not available. Add Azure Login action before this action or provide publish-profile input."); - } - }); - } - static getResourceDetails(params) { - return __awaiter(this, void 0, void 0, function* () { - let appDetails = yield AzureResourceFilterUtility_1.AzureResourceFilterUtility.getAppDetails(params.endpoint, params.appName); - params.resourceGroupName = appDetails["resourceGroupName"]; - params.realKind = appDetails["kind"]; - params.kind = actionparameters_1.appKindMap.get(params.realKind); - //app kind linux and kubeapp is supported only on linux environment currently - params.isLinux = params.realKind.indexOf("linux") > -1 || params.realKind.indexOf("kubeapp") > -1; - }); - } - static setResourceDetails(actionParams) { - return __awaiter(this, void 0, void 0, function* () { - const publishProfile = PublishProfile_1.PublishProfile.getPublishProfile(actionParams.publishProfileContent); - const appOS = yield publishProfile.getAppOS(); - actionParams.isLinux = appOS.includes(RuntimeConstants_1.default.Unix) || appOS.includes(RuntimeConstants_1.default.Unix.toLowerCase()); - }); - } -} -exports.ValidatorFactory = ValidatorFactory; +"use strict"; +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()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const actionparameters_1 = require("../actionparameters"); +const AzureResourceFilterUtility_1 = require("azure-actions-appservice-rest/Utilities/AzureResourceFilterUtility"); +const BaseWebAppDeploymentProvider_1 = require("../DeploymentProvider/Providers/BaseWebAppDeploymentProvider"); +const PublishProfileWebAppValidator_1 = require("./ActionValidators/PublishProfileWebAppValidator"); +const PublishProfileContainerWebAppValidator_1 = require("./ActionValidators/PublishProfileContainerWebAppValidator"); +const SpnLinuxContainerWebAppValidator_1 = require("./ActionValidators/SpnLinuxContainerWebAppValidator"); +const SpnLinuxWebAppValidator_1 = require("./ActionValidators/SpnLinuxWebAppValidator"); +const SpnWindowsContainerWebAppValidator_1 = require("./ActionValidators/SpnWindowsContainerWebAppValidator"); +const SpnWindowsWebAppValidator_1 = require("./ActionValidators/SpnWindowsWebAppValidator"); +const Validations_1 = require("./Validations"); +const PublishProfile_1 = require("../Utilities/PublishProfile"); +const RuntimeConstants_1 = __importDefault(require("../RuntimeConstants")); +class ValidatorFactory { + static getValidator(type) { + return __awaiter(this, void 0, void 0, function* () { + let actionParams = actionparameters_1.ActionParameters.getActionParams(); + if (type === BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE) { + if (!!actionParams.images) { + yield this.setResourceDetails(actionParams); + return new PublishProfileContainerWebAppValidator_1.PublishProfileContainerWebAppValidator(); + } + else { + return new PublishProfileWebAppValidator_1.PublishProfileWebAppValidator(); + } + } + else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) { + // app-name is required to get resource details + Validations_1.appNameIsRequired(actionParams.appName); + yield this.getResourceDetails(actionParams); + if (!!actionParams.isLinux) { + if (!!actionParams.images) { + return new SpnLinuxContainerWebAppValidator_1.SpnLinuxContainerWebAppValidator(); + } + else { + return new SpnLinuxWebAppValidator_1.SpnLinuxWebAppValidator(); + } + } + else { + if (!!actionParams.images) { + return new SpnWindowsContainerWebAppValidator_1.SpnWindowsContainerWebAppValidator(); + } + else { + return new SpnWindowsWebAppValidator_1.SpnWindowsWebAppValidator(); + } + } + } + else { + throw new Error("Valid credentails are not available. Add Azure Login action before this action or provide publish-profile input."); + } + }); + } + static getResourceDetails(params) { + return __awaiter(this, void 0, void 0, function* () { + let appDetails = yield AzureResourceFilterUtility_1.AzureResourceFilterUtility.getAppDetails(params.endpoint, params.appName); + params.resourceGroupName = appDetails["resourceGroupName"]; + params.realKind = appDetails["kind"]; + params.kind = actionparameters_1.appKindMap.get(params.realKind); + //app kind linux and kubeapp is supported only on linux environment currently + params.isLinux = params.realKind.indexOf("linux") > -1 || params.realKind.indexOf("kubeapp") > -1; + }); + } + static setResourceDetails(actionParams) { + return __awaiter(this, void 0, void 0, function* () { + const publishProfile = PublishProfile_1.PublishProfile.getPublishProfile(actionParams.publishProfileContent); + const appOS = yield publishProfile.getAppOS(); + actionParams.isLinux = appOS.includes(RuntimeConstants_1.default.Unix) || appOS.includes(RuntimeConstants_1.default.Unix.toLowerCase()); + }); + } +} +exports.ValidatorFactory = ValidatorFactory; + diff --git a/lib/DeploymentProvider/DeploymentProviderFactory.js b/lib/DeploymentProvider/DeploymentProviderFactory.js index 073066580..688765424 100644 --- a/lib/DeploymentProvider/DeploymentProviderFactory.js +++ b/lib/DeploymentProvider/DeploymentProviderFactory.js @@ -1,31 +1,31 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const actionparameters_1 = require("../actionparameters"); -const BaseWebAppDeploymentProvider_1 = require("./Providers/BaseWebAppDeploymentProvider"); -const WebAppContainerDeployment_1 = require("./Providers/WebAppContainerDeployment"); -const WebAppDeploymentProvider_1 = require("./Providers/WebAppDeploymentProvider"); -const PublishProfileWebAppContainerDeploymentProvider_1 = require("./Providers/PublishProfileWebAppContainerDeploymentProvider"); -class DeploymentProviderFactory { - static getDeploymentProvider(type) { - if (type === BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE) { - if (!!actionparameters_1.ActionParameters.getActionParams().images) { - return new PublishProfileWebAppContainerDeploymentProvider_1.PublishProfileWebAppContainerDeploymentProvider(type); - } - else { - return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type); - } - } - else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) { - if (!!actionparameters_1.ActionParameters.getActionParams().images) { - return new WebAppContainerDeployment_1.WebAppContainerDeploymentProvider(type); - } - else { - return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type); - } - } - else { - throw new Error("Invalid deployment provider type."); - } - } -} -exports.DeploymentProviderFactory = DeploymentProviderFactory; +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const actionparameters_1 = require("../actionparameters"); +const BaseWebAppDeploymentProvider_1 = require("./Providers/BaseWebAppDeploymentProvider"); +const WebAppContainerDeployment_1 = require("./Providers/WebAppContainerDeployment"); +const WebAppDeploymentProvider_1 = require("./Providers/WebAppDeploymentProvider"); +const PublishProfileWebAppContainerDeploymentProvider_1 = require("./Providers/PublishProfileWebAppContainerDeploymentProvider"); +class DeploymentProviderFactory { + static getDeploymentProvider(type) { + if (type === BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE) { + if (!!actionparameters_1.ActionParameters.getActionParams().images) { + return new PublishProfileWebAppContainerDeploymentProvider_1.PublishProfileWebAppContainerDeploymentProvider(type); + } + else { + return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type); + } + } + else if (type == BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN) { + if (!!actionparameters_1.ActionParameters.getActionParams().images) { + return new WebAppContainerDeployment_1.WebAppContainerDeploymentProvider(type); + } + else { + return new WebAppDeploymentProvider_1.WebAppDeploymentProvider(type); + } + } + else { + throw new Error("Invalid deployment provider type."); + } + } +} +exports.DeploymentProviderFactory = DeploymentProviderFactory; diff --git a/lib/DeploymentProvider/Providers/BaseWebAppDeploymentProvider.js b/lib/DeploymentProvider/Providers/BaseWebAppDeploymentProvider.js index 09d632ba3..82ae92b07 100644 --- a/lib/DeploymentProvider/Providers/BaseWebAppDeploymentProvider.js +++ b/lib/DeploymentProvider/Providers/BaseWebAppDeploymentProvider.js @@ -1,82 +1,82 @@ -"use strict"; -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()); - }); -}; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(require("@actions/core")); -const PublishProfile_1 = require("../../Utilities/PublishProfile"); -const actionparameters_1 = require("../../actionparameters"); -const azure_app_service_1 = require("azure-actions-appservice-rest/Arm/azure-app-service"); -const AzureAppServiceUtility_1 = require("azure-actions-appservice-rest/Utilities/AzureAppServiceUtility"); -const KuduServiceUtility_1 = require("azure-actions-appservice-rest/Utilities/KuduServiceUtility"); -const AnnotationUtility_1 = require("azure-actions-appservice-rest/Utilities/AnnotationUtility"); -class BaseWebAppDeploymentProvider { - constructor(type) { - this.authType = type; - this.actionParams = actionparameters_1.ActionParameters.getActionParams(); - } - PreDeploymentStep() { - return __awaiter(this, void 0, void 0, function* () { - switch (this.authType) { - case DEPLOYMENT_PROVIDER_TYPES.SPN: - yield this.initializeForSPN(); - break; - case DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE: - yield this.initializeForPublishProfile(); - break; - default: - throw new Error("Invalid deployment provider type"); - } - }); - } - UpdateDeploymentStatus(isDeploymentSuccess) { - return __awaiter(this, void 0, void 0, function* () { - if (!!this.appService) { - yield AnnotationUtility_1.addAnnotation(this.actionParams.endpoint, this.appService, isDeploymentSuccess); - } - this.activeDeploymentID = yield this.kuduServiceUtility.updateDeploymentStatus(isDeploymentSuccess, null, { 'type': 'Deployment', slotName: this.actionParams.slotName }); - core.debug('Active DeploymentId :' + this.activeDeploymentID); - if (!!isDeploymentSuccess && !!this.deploymentID && !!this.activeDeploymentID) { - yield this.kuduServiceUtility.postZipDeployOperation(this.deploymentID, this.activeDeploymentID); - } - console.log('App Service Application URL: ' + this.applicationURL); - core.setOutput('webapp-url', this.applicationURL); - }); - } - initializeForSPN() { - return __awaiter(this, void 0, void 0, function* () { - this.appService = new azure_app_service_1.AzureAppService(this.actionParams.endpoint, this.actionParams.resourceGroupName, this.actionParams.appName, this.actionParams.slotName); - this.appServiceUtility = new AzureAppServiceUtility_1.AzureAppServiceUtility(this.appService); - this.kuduService = yield this.appServiceUtility.getKuduService(); - this.kuduServiceUtility = new KuduServiceUtility_1.KuduServiceUtility(this.kuduService); - this.applicationURL = yield this.appServiceUtility.getApplicationURL(); - }); - } - initializeForPublishProfile() { - return __awaiter(this, void 0, void 0, function* () { - const publishProfile = PublishProfile_1.PublishProfile.getPublishProfile(this.actionParams.publishProfileContent); - this.kuduService = publishProfile.kuduService; - this.kuduServiceUtility = new KuduServiceUtility_1.KuduServiceUtility(this.kuduService); - this.applicationURL = publishProfile.appUrl; - }); - } -} -exports.BaseWebAppDeploymentProvider = BaseWebAppDeploymentProvider; -var DEPLOYMENT_PROVIDER_TYPES; -(function (DEPLOYMENT_PROVIDER_TYPES) { - DEPLOYMENT_PROVIDER_TYPES[DEPLOYMENT_PROVIDER_TYPES["SPN"] = 0] = "SPN"; - DEPLOYMENT_PROVIDER_TYPES[DEPLOYMENT_PROVIDER_TYPES["PUBLISHPROFILE"] = 1] = "PUBLISHPROFILE"; -})(DEPLOYMENT_PROVIDER_TYPES = exports.DEPLOYMENT_PROVIDER_TYPES || (exports.DEPLOYMENT_PROVIDER_TYPES = {})); +"use strict"; +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()); + }); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(require("@actions/core")); +const PublishProfile_1 = require("../../Utilities/PublishProfile"); +const actionparameters_1 = require("../../actionparameters"); +const azure_app_service_1 = require("azure-actions-appservice-rest/Arm/azure-app-service"); +const AzureAppServiceUtility_1 = require("azure-actions-appservice-rest/Utilities/AzureAppServiceUtility"); +const KuduServiceUtility_1 = require("azure-actions-appservice-rest/Utilities/KuduServiceUtility"); +const AnnotationUtility_1 = require("azure-actions-appservice-rest/Utilities/AnnotationUtility"); +class BaseWebAppDeploymentProvider { + constructor(type) { + this.authType = type; + this.actionParams = actionparameters_1.ActionParameters.getActionParams(); + } + PreDeploymentStep() { + return __awaiter(this, void 0, void 0, function* () { + switch (this.authType) { + case DEPLOYMENT_PROVIDER_TYPES.SPN: + yield this.initializeForSPN(); + break; + case DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE: + yield this.initializeForPublishProfile(); + break; + default: + throw new Error("Invalid deployment provider type"); + } + }); + } + UpdateDeploymentStatus(isDeploymentSuccess) { + return __awaiter(this, void 0, void 0, function* () { + if (!!this.appService) { + yield AnnotationUtility_1.addAnnotation(this.actionParams.endpoint, this.appService, isDeploymentSuccess); + } + this.activeDeploymentID = yield this.kuduServiceUtility.updateDeploymentStatus(isDeploymentSuccess, null, { 'type': 'Deployment', slotName: this.actionParams.slotName }); + core.debug('Active DeploymentId :' + this.activeDeploymentID); + if (!!isDeploymentSuccess && !!this.deploymentID && !!this.activeDeploymentID) { + yield this.kuduServiceUtility.postZipDeployOperation(this.deploymentID, this.activeDeploymentID); + } + console.log('App Service Application URL: ' + this.applicationURL); + core.setOutput('webapp-url', this.applicationURL); + }); + } + initializeForSPN() { + return __awaiter(this, void 0, void 0, function* () { + this.appService = new azure_app_service_1.AzureAppService(this.actionParams.endpoint, this.actionParams.resourceGroupName, this.actionParams.appName, this.actionParams.slotName); + this.appServiceUtility = new AzureAppServiceUtility_1.AzureAppServiceUtility(this.appService); + this.kuduService = yield this.appServiceUtility.getKuduService(); + this.kuduServiceUtility = new KuduServiceUtility_1.KuduServiceUtility(this.kuduService); + this.applicationURL = yield this.appServiceUtility.getApplicationURL(); + }); + } + initializeForPublishProfile() { + return __awaiter(this, void 0, void 0, function* () { + const publishProfile = PublishProfile_1.PublishProfile.getPublishProfile(this.actionParams.publishProfileContent); + this.kuduService = publishProfile.kuduService; + this.kuduServiceUtility = new KuduServiceUtility_1.KuduServiceUtility(this.kuduService); + this.applicationURL = publishProfile.appUrl; + }); + } +} +exports.BaseWebAppDeploymentProvider = BaseWebAppDeploymentProvider; +var DEPLOYMENT_PROVIDER_TYPES; +(function (DEPLOYMENT_PROVIDER_TYPES) { + DEPLOYMENT_PROVIDER_TYPES[DEPLOYMENT_PROVIDER_TYPES["SPN"] = 0] = "SPN"; + DEPLOYMENT_PROVIDER_TYPES[DEPLOYMENT_PROVIDER_TYPES["PUBLISHPROFILE"] = 1] = "PUBLISHPROFILE"; +})(DEPLOYMENT_PROVIDER_TYPES = exports.DEPLOYMENT_PROVIDER_TYPES || (exports.DEPLOYMENT_PROVIDER_TYPES = {})); diff --git a/lib/DeploymentProvider/Providers/IWebAppDeploymentProvider.js b/lib/DeploymentProvider/Providers/IWebAppDeploymentProvider.js index ce03781e2..c8ad2e549 100644 --- a/lib/DeploymentProvider/Providers/IWebAppDeploymentProvider.js +++ b/lib/DeploymentProvider/Providers/IWebAppDeploymentProvider.js @@ -1,2 +1,2 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/lib/DeploymentProvider/Providers/WebAppContainerDeployment.js b/lib/DeploymentProvider/Providers/WebAppContainerDeployment.js index fd9aa8d2c..b40c620e6 100644 --- a/lib/DeploymentProvider/Providers/WebAppContainerDeployment.js +++ b/lib/DeploymentProvider/Providers/WebAppContainerDeployment.js @@ -1,27 +1,27 @@ -"use strict"; -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 }); -const BaseWebAppDeploymentProvider_1 = require("./BaseWebAppDeploymentProvider"); -const ContainerDeploymentUtility_1 = require("azure-actions-appservice-rest/Utilities/ContainerDeploymentUtility"); -class WebAppContainerDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebAppDeploymentProvider { - DeployWebAppStep() { - return __awaiter(this, void 0, void 0, function* () { - let containerDeploymentUtility = new ContainerDeploymentUtility_1.ContainerDeploymentUtility(this.appService); - let images = this.actionParams.images; - let configFile = this.actionParams.multiContainerConfigFile; - let isLinux = this.actionParams.isLinux; - let isMultiContainer = this.actionParams.isMultiContainer; - let startupCommand = this.actionParams.startupCommand; - yield containerDeploymentUtility.deployWebAppImage(images, configFile, isLinux, isMultiContainer, startupCommand); - }); - } -} -exports.WebAppContainerDeploymentProvider = WebAppContainerDeploymentProvider; +"use strict"; +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 }); +const BaseWebAppDeploymentProvider_1 = require("./BaseWebAppDeploymentProvider"); +const ContainerDeploymentUtility_1 = require("azure-actions-appservice-rest/Utilities/ContainerDeploymentUtility"); +class WebAppContainerDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebAppDeploymentProvider { + DeployWebAppStep() { + return __awaiter(this, void 0, void 0, function* () { + let containerDeploymentUtility = new ContainerDeploymentUtility_1.ContainerDeploymentUtility(this.appService); + let images = this.actionParams.images; + let configFile = this.actionParams.multiContainerConfigFile; + let isLinux = this.actionParams.isLinux; + let isMultiContainer = this.actionParams.isMultiContainer; + let startupCommand = this.actionParams.startupCommand; + yield containerDeploymentUtility.deployWebAppImage(images, configFile, isLinux, isMultiContainer, startupCommand); + }); + } +} +exports.WebAppContainerDeploymentProvider = WebAppContainerDeploymentProvider; diff --git a/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js b/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js index c0d478e26..35fa5b607 100644 --- a/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js +++ b/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js @@ -1,79 +1,79 @@ -"use strict"; -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()); - }); -}; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -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"); -class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebAppDeploymentProvider { - DeployWebAppStep() { - return __awaiter(this, void 0, void 0, function* () { - let appPackage = this.actionParams.package; - let webPackage = appPackage.getPath(); - // kudu warm up - yield this.kuduServiceUtility.warmpUp(); - let packageType = appPackage.getPackageType(); - switch (packageType) { - case packageUtility_1.PackageType.war: - core.debug("Initiated deployment via kudu service for webapp war package : " + webPackage); - var warName = utility.getFileNameFromPath(webPackage, ".war"); - this.deploymentID = yield this.kuduServiceUtility.deployUsingWarDeploy(webPackage, { slotName: this.actionParams.slotName }, warName); - break; - case packageUtility_1.PackageType.jar: - core.debug("Initiated deployment via kudu service for webapp jar package : " + webPackage); - let folderPath = yield utility.generateTemporaryFolderForDeployment(false, webPackage, packageUtility_1.PackageType.jar); - let output = yield utility.archiveFolderForDeployment(false, folderPath); - webPackage = output.webDeployPkg; - this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage); - 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.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage); - break; - case packageUtility_1.PackageType.zip: - core.debug("Initiated deployment via kudu service for webapp package : " + webPackage); - this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage); - break; - default: - throw new Error('Invalid App Service package or folder path provided: ' + webPackage); - } - // 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}`); - } - }); - } -} -exports.WebAppDeploymentProvider = WebAppDeploymentProvider; +"use strict"; +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()); + }); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +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"); +class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebAppDeploymentProvider { + DeployWebAppStep() { + return __awaiter(this, void 0, void 0, function* () { + let appPackage = this.actionParams.package; + let webPackage = appPackage.getPath(); + // kudu warm up + yield this.kuduServiceUtility.warmpUp(); + let packageType = appPackage.getPackageType(); + switch (packageType) { + case packageUtility_1.PackageType.war: + core.debug("Initiated deployment via kudu service for webapp war package : " + webPackage); + var warName = utility.getFileNameFromPath(webPackage, ".war"); + this.deploymentID = yield this.kuduServiceUtility.deployUsingWarDeploy(webPackage, { slotName: this.actionParams.slotName }, warName); + break; + case packageUtility_1.PackageType.jar: + core.debug("Initiated deployment via kudu service for webapp jar package : " + webPackage); + let folderPath = yield utility.generateTemporaryFolderForDeployment(false, webPackage, packageUtility_1.PackageType.jar); + let output = yield utility.archiveFolderForDeployment(false, folderPath); + webPackage = output.webDeployPkg; + this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage); + 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.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage); + break; + case packageUtility_1.PackageType.zip: + core.debug("Initiated deployment via kudu service for webapp package : " + webPackage); + this.deploymentID = yield this.kuduServiceUtility.deployUsingZipDeploy(webPackage); + break; + default: + throw new Error('Invalid App Service package or folder path provided: ' + webPackage); + } + // 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}`); + } + }); + } +} +exports.WebAppDeploymentProvider = WebAppDeploymentProvider; diff --git a/lib/Utilities/PublishProfile.js b/lib/Utilities/PublishProfile.js index db023ac4d..d88b94856 100644 --- a/lib/Utilities/PublishProfile.js +++ b/lib/Utilities/PublishProfile.js @@ -1,71 +1,71 @@ -"use strict"; -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()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var core = require("@actions/core"); -const actions_secret_parser_1 = require("actions-secret-parser"); -const azure_app_kudu_service_1 = require("azure-actions-appservice-rest/Kudu/azure-app-kudu-service"); -const RuntimeConstants_1 = __importDefault(require("../RuntimeConstants")); -class PublishProfile { - constructor(publishProfileContent) { - try { - let secrets = new actions_secret_parser_1.SecretParser(publishProfileContent, actions_secret_parser_1.FormatType.XML); - this._creds = { - uri: secrets.getSecret("//publishProfile/@publishUrl", false), - username: secrets.getSecret("//publishProfile/@userName", true), - password: secrets.getSecret("//publishProfile/@userPWD", true) - }; - this._appUrl = secrets.getSecret("//publishProfile/@destinationAppUrl", false); - if (this._creds.uri.indexOf("scm") < 0) { - throw new Error("Publish profile does not contain kudu URL"); - } - this._creds.uri = `https://${this._creds.uri}`; - this._kuduService = new azure_app_kudu_service_1.Kudu(this._creds.uri, this._creds.username, this._creds.password); - } - catch (error) { - core.error("Failed to fetch credentials from Publish Profile. For more details on how to set publish profile credentials refer https://aka.ms/create-secrets-for-GitHub-workflows"); - throw error; - } - } - static getPublishProfile(publishProfileContent) { - if (!this._publishProfile) { - this._publishProfile = new PublishProfile(publishProfileContent); - } - return this._publishProfile; - } - get creds() { - return this._creds; - } - get appUrl() { - return this._appUrl; - } - get kuduService() { - return this._kuduService; - } - getAppOS() { - return __awaiter(this, void 0, void 0, function* () { - try { - if (!this._appOS) { - const appRuntimeDetails = yield this._kuduService.getAppRuntime(); - this._appOS = appRuntimeDetails[RuntimeConstants_1.default.system][RuntimeConstants_1.default.osName]; - core.debug(`App Runtime OS: ${this._appOS}`); - } - } - catch (error) { - throw Error("Failed to get app runtime OS\n" + JSON.stringify(error)); - } - return this._appOS; - }); - } -} -exports.PublishProfile = PublishProfile; +"use strict"; +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()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var core = require("@actions/core"); +const actions_secret_parser_1 = require("actions-secret-parser"); +const azure_app_kudu_service_1 = require("azure-actions-appservice-rest/Kudu/azure-app-kudu-service"); +const RuntimeConstants_1 = __importDefault(require("../RuntimeConstants")); +class PublishProfile { + constructor(publishProfileContent) { + try { + let secrets = new actions_secret_parser_1.SecretParser(publishProfileContent, actions_secret_parser_1.FormatType.XML); + this._creds = { + uri: secrets.getSecret("//publishProfile/@publishUrl", false), + username: secrets.getSecret("//publishProfile/@userName", true), + password: secrets.getSecret("//publishProfile/@userPWD", true) + }; + this._appUrl = secrets.getSecret("//publishProfile/@destinationAppUrl", false); + if (this._creds.uri.indexOf("scm") < 0) { + throw new Error("Publish profile does not contain kudu URL"); + } + this._creds.uri = `https://${this._creds.uri}`; + this._kuduService = new azure_app_kudu_service_1.Kudu(this._creds.uri, this._creds.username, this._creds.password); + } + catch (error) { + core.error("Failed to fetch credentials from Publish Profile. For more details on how to set publish profile credentials refer https://aka.ms/create-secrets-for-GitHub-workflows"); + throw error; + } + } + static getPublishProfile(publishProfileContent) { + if (!this._publishProfile) { + this._publishProfile = new PublishProfile(publishProfileContent); + } + return this._publishProfile; + } + get creds() { + return this._creds; + } + get appUrl() { + return this._appUrl; + } + get kuduService() { + return this._kuduService; + } + getAppOS() { + return __awaiter(this, void 0, void 0, function* () { + try { + if (!this._appOS) { + const appRuntimeDetails = yield this._kuduService.getAppRuntime(); + this._appOS = appRuntimeDetails[RuntimeConstants_1.default.system][RuntimeConstants_1.default.osName]; + core.debug(`App Runtime OS: ${this._appOS}`); + } + } + catch (error) { + throw Error("Failed to get app runtime OS\n" + JSON.stringify(error)); + } + return this._appOS; + }); + } +} +exports.PublishProfile = PublishProfile; diff --git a/lib/actionparameters.js b/lib/actionparameters.js index 5f662db1d..1a2edfbde 100644 --- a/lib/actionparameters.js +++ b/lib/actionparameters.js @@ -1,103 +1,103 @@ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(require("@actions/core")); -var WebAppKind; -(function (WebAppKind) { - WebAppKind[WebAppKind["Windows"] = 0] = "Windows"; - WebAppKind[WebAppKind["Linux"] = 1] = "Linux"; - WebAppKind[WebAppKind["WindowsContainer"] = 2] = "WindowsContainer"; - WebAppKind[WebAppKind["LinuxContainer"] = 3] = "LinuxContainer"; -})(WebAppKind = exports.WebAppKind || (exports.WebAppKind = {})); -; -exports.appKindMap = new Map([ - ['app', WebAppKind.Windows], - ['app,linux', WebAppKind.Linux], - ['app,container,windows', WebAppKind.WindowsContainer], - ['app,linux,container', WebAppKind.LinuxContainer] -]); -class ActionParameters { - constructor(endpoint) { - this._publishProfileContent = core.getInput('publish-profile'); - this._appName = core.getInput('app-name'); - this._slotName = core.getInput('slot-name'); - this._packageInput = core.getInput('package'); - this._images = core.getInput('images'); - this._multiContainerConfigFile = core.getInput('configuration-file'); - this._startupCommand = core.getInput('startup-command'); - this._endpoint = endpoint; - } - static getActionParams(endpoint) { - if (!this.actionparams) { - this.actionparams = new ActionParameters(!!endpoint ? endpoint : null); - } - return this.actionparams; - } - get appName() { - return this._appName; - } - get packageInput() { - return this._packageInput; - } - get package() { - return this._package; - } - set package(appPackage) { - this._package = appPackage; - } - get images() { - return this._images; - } - get resourceGroupName() { - return this._resourceGroupName; - } - set resourceGroupName(rg) { - this._resourceGroupName = rg; - } - get kind() { - return this._kind; - } - set kind(kind) { - this._kind = kind; - } - get realKind() { - return this._realKind; - } - set realKind(kind) { - this._realKind = kind; - } - get endpoint() { - return this._endpoint; - } - get publishProfileContent() { - return this._publishProfileContent; - } - get slotName() { - return this._slotName; - } - get isMultiContainer() { - return this._isMultiContainer; - } - set isMultiContainer(isMultiCont) { - this._isMultiContainer = isMultiCont; - } - get isLinux() { - return this._isLinux; - } - set isLinux(isLin) { - this._isLinux = isLin; - } - get startupCommand() { - return this._startupCommand; - } - get multiContainerConfigFile() { - return this._multiContainerConfigFile; - } -} -exports.ActionParameters = ActionParameters; +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(require("@actions/core")); +var WebAppKind; +(function (WebAppKind) { + WebAppKind[WebAppKind["Windows"] = 0] = "Windows"; + WebAppKind[WebAppKind["Linux"] = 1] = "Linux"; + WebAppKind[WebAppKind["WindowsContainer"] = 2] = "WindowsContainer"; + WebAppKind[WebAppKind["LinuxContainer"] = 3] = "LinuxContainer"; +})(WebAppKind = exports.WebAppKind || (exports.WebAppKind = {})); +; +exports.appKindMap = new Map([ + ['app', WebAppKind.Windows], + ['app,linux', WebAppKind.Linux], + ['app,container,windows', WebAppKind.WindowsContainer], + ['app,linux,container', WebAppKind.LinuxContainer] +]); +class ActionParameters { + constructor(endpoint) { + this._publishProfileContent = core.getInput('publish-profile'); + this._appName = core.getInput('app-name'); + this._slotName = core.getInput('slot-name'); + this._packageInput = core.getInput('package'); + this._images = core.getInput('images'); + this._multiContainerConfigFile = core.getInput('configuration-file'); + this._startupCommand = core.getInput('startup-command'); + this._endpoint = endpoint; + } + static getActionParams(endpoint) { + if (!this.actionparams) { + this.actionparams = new ActionParameters(!!endpoint ? endpoint : null); + } + return this.actionparams; + } + get appName() { + return this._appName; + } + get packageInput() { + return this._packageInput; + } + get package() { + return this._package; + } + set package(appPackage) { + this._package = appPackage; + } + get images() { + return this._images; + } + get resourceGroupName() { + return this._resourceGroupName; + } + set resourceGroupName(rg) { + this._resourceGroupName = rg; + } + get kind() { + return this._kind; + } + set kind(kind) { + this._kind = kind; + } + get realKind() { + return this._realKind; + } + set realKind(kind) { + this._realKind = kind; + } + get endpoint() { + return this._endpoint; + } + get publishProfileContent() { + return this._publishProfileContent; + } + get slotName() { + return this._slotName; + } + get isMultiContainer() { + return this._isMultiContainer; + } + set isMultiContainer(isMultiCont) { + this._isMultiContainer = isMultiCont; + } + get isLinux() { + return this._isLinux; + } + set isLinux(isLin) { + this._isLinux = isLin; + } + get startupCommand() { + return this._startupCommand; + } + get multiContainerConfigFile() { + return this._multiContainerConfigFile; + } +} +exports.ActionParameters = ActionParameters; diff --git a/lib/main.js b/lib/main.js index 1d8954a77..4517adbbf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,70 +1,70 @@ -"use strict"; -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()); - }); -}; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(require("@actions/core")); -const crypto = __importStar(require("crypto")); -const actionparameters_1 = require("./actionparameters"); -const AuthorizerFactory_1 = require("azure-actions-webclient/AuthorizerFactory"); -const BaseWebAppDeploymentProvider_1 = require("./DeploymentProvider/Providers/BaseWebAppDeploymentProvider"); -const DeploymentProviderFactory_1 = require("./DeploymentProvider/DeploymentProviderFactory"); -const ValidatorFactory_1 = require("./ActionInputValidator/ValidatorFactory"); -var prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : ""; -function main() { - return __awaiter(this, void 0, void 0, function* () { - let isDeploymentSuccess = true; - try { - // Set user agent variable - let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex'); - let actionName = 'DeployWebAppToAzure'; - let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS_${actionName}_${usrAgentRepo}`; - core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString); - // Initialize action inputs - let endpoint = !!core.getInput('publish-profile') ? null : yield AuthorizerFactory_1.AuthorizerFactory.getAuthorizer(); - actionparameters_1.ActionParameters.getActionParams(endpoint); - let type = null; - if (!!endpoint) { - type = BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN; - } - else { - type = BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE; - } - // Validate action inputs - let validator = yield ValidatorFactory_1.ValidatorFactory.getValidator(type); - yield validator.validate(); - var deploymentProvider = DeploymentProviderFactory_1.DeploymentProviderFactory.getDeploymentProvider(type); - core.debug("Predeployment Step Started"); - yield deploymentProvider.PreDeploymentStep(); - core.debug("Deployment Step Started"); - yield deploymentProvider.DeployWebAppStep(); - } - catch (error) { - isDeploymentSuccess = false; - core.setFailed("Deployment Failed with Error: " + error); - } - finally { - if (deploymentProvider != null) { - yield deploymentProvider.UpdateDeploymentStatus(isDeploymentSuccess); - } - // Reset AZURE_HTTP_USER_AGENT - core.exportVariable('AZURE_HTTP_USER_AGENT', prefix); - core.debug(isDeploymentSuccess ? "Deployment Succeeded" : "Deployment failed"); - } - }); -} -exports.main = main; -main(); +"use strict"; +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()); + }); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(require("@actions/core")); +const crypto = __importStar(require("crypto")); +const actionparameters_1 = require("./actionparameters"); +const AuthorizerFactory_1 = require("azure-actions-webclient/AuthorizerFactory"); +const BaseWebAppDeploymentProvider_1 = require("./DeploymentProvider/Providers/BaseWebAppDeploymentProvider"); +const DeploymentProviderFactory_1 = require("./DeploymentProvider/DeploymentProviderFactory"); +const ValidatorFactory_1 = require("./ActionInputValidator/ValidatorFactory"); +var prefix = !!process.env.AZURE_HTTP_USER_AGENT ? `${process.env.AZURE_HTTP_USER_AGENT}` : ""; +function main() { + return __awaiter(this, void 0, void 0, function* () { + let isDeploymentSuccess = true; + try { + // Set user agent variable + let usrAgentRepo = crypto.createHash('sha256').update(`${process.env.GITHUB_REPOSITORY}`).digest('hex'); + let actionName = 'DeployWebAppToAzure'; + let userAgentString = (!!prefix ? `${prefix}+` : '') + `GITHUBACTIONS_${actionName}_${usrAgentRepo}`; + core.exportVariable('AZURE_HTTP_USER_AGENT', userAgentString); + // Initialize action inputs + let endpoint = !!core.getInput('publish-profile') ? null : yield AuthorizerFactory_1.AuthorizerFactory.getAuthorizer(); + actionparameters_1.ActionParameters.getActionParams(endpoint); + let type = null; + if (!!endpoint) { + type = BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.SPN; + } + else { + type = BaseWebAppDeploymentProvider_1.DEPLOYMENT_PROVIDER_TYPES.PUBLISHPROFILE; + } + // Validate action inputs + let validator = yield ValidatorFactory_1.ValidatorFactory.getValidator(type); + yield validator.validate(); + var deploymentProvider = DeploymentProviderFactory_1.DeploymentProviderFactory.getDeploymentProvider(type); + core.debug("Predeployment Step Started"); + yield deploymentProvider.PreDeploymentStep(); + core.debug("Deployment Step Started"); + yield deploymentProvider.DeployWebAppStep(); + } + catch (error) { + isDeploymentSuccess = false; + core.setFailed("Deployment Failed with Error: " + error); + } + finally { + if (deploymentProvider != null) { + yield deploymentProvider.UpdateDeploymentStatus(isDeploymentSuccess); + } + // Reset AZURE_HTTP_USER_AGENT + core.exportVariable('AZURE_HTTP_USER_AGENT', prefix); + core.debug(isDeploymentSuccess ? "Deployment Succeeded" : "Deployment failed"); + } + }); +} +exports.main = main; +main(); diff --git a/package-lock.json b/package-lock.json index 84d619ef3..dee081014 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,9 +10,9 @@ "integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA==" }, "@actions/exec": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.3.tgz", - "integrity": "sha512-TogJGnueOmM7ntCi0ASTUj4LapRRtDfj57Ja4IhPmg2fls28uVOPbAn8N+JifaOumN2UG3oEO/Ixek2A4NcYSA==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.4.tgz", + "integrity": "sha512-4DPChWow9yc9W3WqEbUj8Nr86xkpyE29ZzWjXucHItclLbEW6jr80Zx4nqv18QL6KK65+cifiQZXvnqgTV6oHw==", "requires": { "@actions/io": "^1.0.1" } @@ -55,12 +55,6 @@ "source-map": "^0.5.0" }, "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - }, "semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", @@ -145,14 +139,6 @@ "@babel/template": "^7.10.4", "@babel/types": "^7.11.0", "lodash": "^4.17.19" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - } } }, "@babel/helper-optimise-call-expression": { @@ -412,14 +398,6 @@ "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.19" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - } } }, "@babel/types": { @@ -431,14 +409,6 @@ "@babel/helper-validator-identifier": "^7.10.4", "lodash": "^4.17.19", "to-fast-properties": "^2.0.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - } } }, "@bcoe/v8-coverage": { @@ -1026,6 +996,11 @@ "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=", "dev": true }, + "array-filter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-1.0.0.tgz", + "integrity": "sha1-uveeYubvTCpMC4MSMtr/7CUfnYM=" + }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", @@ -1079,6 +1054,14 @@ "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "dev": true }, + "available-typed-arrays": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz", + "integrity": "sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ==", + "requires": { + "array-filter": "^1.0.0" + } + }, "aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -1092,17 +1075,25 @@ "dev": true }, "azure-actions-appservice-rest": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/azure-actions-appservice-rest/-/azure-actions-appservice-rest-1.2.9.tgz", - "integrity": "sha512-+E8T+dF2gh1GMrvA00KyhN1k7g1ZIfAceE6cF9nRWfNVvF6SHDP3fcdTaodY07rBaFf0buonyfMf3DJRc6m2iw==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/azure-actions-appservice-rest/-/azure-actions-appservice-rest-1.3.1.tgz", + "integrity": "sha512-8tLCqWnExGX3e+zKTAWm7lI64UVyJ/jWhLjAifGNtVUhwYtHpCX3B7XSPT7kHg/D7NydYHwHnTE7uJQoE6EFVA==", "requires": { "@actions/core": "^1.1.1", "@actions/io": "^1.0.1", - "azure-actions-webclient": "^1.0.8", + "@types/node": "^14.14.31", + "azure-actions-webclient": "^1.1.0", "fs": "0.0.1-security", "util": "^0.12.1", "uuid": "^3.3.3", "xml2js": "^0.4.22" + }, + "dependencies": { + "@types/node": { + "version": "14.14.37", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.37.tgz", + "integrity": "sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw==" + } } }, "azure-actions-utility": { @@ -1122,9 +1113,9 @@ } }, "azure-actions-webclient": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/azure-actions-webclient/-/azure-actions-webclient-1.0.11.tgz", - "integrity": "sha512-4l0V47W3DDreTFCXEdhWr9LhmgSZecWWyKhm06XOAUodQ82x9ndFFet4OywCDcvQ1u4Gh11xPaSv62FACcgyyw==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/azure-actions-webclient/-/azure-actions-webclient-1.1.0.tgz", + "integrity": "sha512-NbTOiGCuJvLSGg18Rc/DUV2VsyI6deSCeO7Lp/81gFt/EjvrOrH+3pp8kl1CHGAvRXkwvQsyeKEMdiOBk0/5eg==", "requires": { "@actions/core": "^1.1.3", "@actions/exec": "^1.0.1", @@ -1297,9 +1288,9 @@ } }, "bl": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", - "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", "requires": { "readable-stream": "^2.3.5", "safe-buffer": "^5.1.1" @@ -1425,6 +1416,15 @@ "unset-value": "^1.0.0" } }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -1881,21 +1881,26 @@ } }, "es-abstract": { - "version": "1.17.4", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.4.tgz", - "integrity": "sha512-Ae3um/gb8F0mui/jPL+QiqmglkUsaQf7FwBEHYIFkztkneosu9imhqHpBzQ3h1vit8t5iQ74t6PEVvphBZiuiQ==", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0.tgz", + "integrity": "sha512-LJzK7MrQa8TS0ja2w3YNLzUgJCGPdPOV1yVvezjNnS89D+VR08+Szt2mz3YB2Dck/+w5tfIq/RoUAFqJJGM2yw==", "requires": { + "call-bind": "^1.0.2", "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", + "get-intrinsic": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.1.5", - "is-regex": "^1.0.5", - "object-inspect": "^1.7.0", + "has-symbols": "^1.0.2", + "is-callable": "^1.2.3", + "is-negative-zero": "^2.0.1", + "is-regex": "^1.1.2", + "is-string": "^1.0.5", + "object-inspect": "^1.9.0", "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimleft": "^2.1.1", - "string.prototype.trimright": "^2.1.1" + "object.assign": "^4.1.2", + "string.prototype.trimend": "^1.0.4", + "string.prototype.trimstart": "^1.0.4", + "unbox-primitive": "^1.0.0" } }, "es-to-primitive": { @@ -2188,6 +2193,11 @@ "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", "dev": true }, + "foreach": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", + "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=" + }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -2253,6 +2263,16 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + }, "get-package-type": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", @@ -2338,6 +2358,11 @@ "function-bind": "^1.1.1" } }, + "has-bigints": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", + "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==" + }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -2345,9 +2370,9 @@ "dev": true }, "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==" }, "has-value": { "version": "1.0.0", @@ -2510,9 +2535,12 @@ } }, "is-arguments": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", - "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.0.tgz", + "integrity": "sha512-1Ij4lOMPl/xB5kBDn7I+b2ttPMKa8szhEIrXDuXQD/oe3HJLTLhqhgGspwgyGd6MOywBUqVvYicF72lkgDnIHg==", + "requires": { + "call-bind": "^1.0.0" + } }, "is-arrayish": { "version": "0.2.1", @@ -2520,6 +2548,19 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, + "is-bigint": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.1.tgz", + "integrity": "sha512-J0ELF4yHFxHy0cmSxZuheDOz2luOdVvqjwmEcj8H/L1JHeuEDSDbeRP+Dk9kFVk5RTFzbucJ2Kb9F7ixY2QaCg==" + }, + "is-boolean-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.0.tgz", + "integrity": "sha512-a7Uprx8UtD+HWdyYwnD1+ExtTgqQtD2k/1yJgtXP6wnMm8byhkoTZRl+95LLThpzNZJ5aEvi46cdH+ayMFRwmA==", + "requires": { + "call-bind": "^1.0.0" + } + }, "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", @@ -2527,9 +2568,9 @@ "dev": true }, "is-callable": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", - "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==" + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.3.tgz", + "integrity": "sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ==" }, "is-ci": { "version": "2.0.0", @@ -2610,9 +2651,14 @@ "dev": true }, "is-generator-function": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.7.tgz", - "integrity": "sha512-YZc5EwyO4f2kWCax7oegfuSr9mFz1ZvieNYBEjmukLxgXfBUbxAWGVF7GZf0zidYtoBl3WvC07YK0wT76a+Rtw==" + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.8.tgz", + "integrity": "sha512-2Omr/twNtufVZFr1GhxjOMFPAj2sjc/dKaIqBhvo4qciXfJmITGH6ZGd8eZYNHza8t1y0e01AuqRhJwfWp26WQ==" + }, + "is-negative-zero": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz", + "integrity": "sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w==" }, "is-number": { "version": "7.0.0", @@ -2620,6 +2666,11 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, + "is-number-object": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.4.tgz", + "integrity": "sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw==" + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -2630,11 +2681,12 @@ } }, "is-regex": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", - "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.2.tgz", + "integrity": "sha512-axvdhb5pdhEVThqJzYXwMlVuZwC+FF2DpcOhTS+y/8jVq4trxyPgfcwIxIKiyeuLlSQYKkmUaPQJ8ZE4yNKXDg==", "requires": { - "has": "^1.0.3" + "call-bind": "^1.0.2", + "has-symbols": "^1.0.1" } }, "is-stream": { @@ -2643,6 +2695,11 @@ "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, + "is-string": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", + "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==" + }, "is-symbol": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", @@ -2651,6 +2708,18 @@ "has-symbols": "^1.0.1" } }, + "is-typed-array": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.5.tgz", + "integrity": "sha512-S+GRDgJlR3PyEbsX/Fobd9cqpZBuvUS+8asRqYDMLCb2qMzt1oz5m5oxQCxOgUDxiWsOVNi4yaF+/uvdlHlYug==", + "requires": { + "available-typed-arrays": "^1.0.2", + "call-bind": "^1.0.2", + "es-abstract": "^1.18.0-next.2", + "foreach": "^2.0.5", + "has-symbols": "^1.0.1" + } + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -3500,9 +3569,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" + "version": "4.17.20", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", + "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==" }, "lodash.memoize": { "version": "4.1.2", @@ -3819,9 +3888,9 @@ } }, "object-inspect": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", - "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==" + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.9.0.tgz", + "integrity": "sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw==" }, "object-keys": { "version": "1.1.1", @@ -3838,25 +3907,14 @@ } }, "object.assign": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", - "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", - "requires": { - "define-properties": "^1.1.2", - "function-bind": "^1.1.1", - "has-symbols": "^1.0.0", - "object-keys": "^1.0.11" - } - }, - "object.entries": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.1.tgz", - "integrity": "sha512-ilqR7BgdyZetJutmDPfXCDffGa0/Yzl2ivVNpbx/g4UeWrCdRnFDUBrKJGLhGieRHDATnyZXWBeCb29k9CJysQ==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", + "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", "requires": { + "call-bind": "^1.0.0", "define-properties": "^1.1.3", - "es-abstract": "^1.17.0-next.1", - "function-bind": "^1.1.1", - "has": "^1.0.3" + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" } }, "object.pick": { @@ -4112,14 +4170,17 @@ "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=" }, "qs": { - "version": "6.9.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.1.tgz", - "integrity": "sha512-Cxm7/SS/y/Z3MHWSxXb8lIFqgqBowP5JMlTUFyJN88y0SGQhVmZnqFK/PeuMX9LzUyWsqqhNxIyg0jlzq946yA==" + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.1.tgz", + "integrity": "sha512-M528Hph6wsSVOBiYUnGf+K/7w0hNshs/duGsNXPUCLH5XAqjEtiPGwNONLV0tBH8NoGb0mvD5JubnUTrujKDTg==", + "requires": { + "side-channel": "^1.0.4" + } }, "querystring": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.1.tgz", + "integrity": "sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==" }, "react-is": { "version": "16.13.1", @@ -4265,14 +4326,6 @@ "dev": true, "requires": { "lodash": "^4.17.19" - }, - "dependencies": { - "lodash": { - "version": "4.17.20", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", - "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", - "dev": true - } } }, "request-promise-native": { @@ -4589,6 +4642,16 @@ "dev": true, "optional": true }, + "side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "requires": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + } + }, "signal-exit": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", @@ -4912,22 +4975,22 @@ "strip-ansi": "^6.0.0" } }, - "string.prototype.trimleft": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", - "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", + "string.prototype.trimend": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz", + "integrity": "sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==", "requires": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" } }, - "string.prototype.trimright": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", - "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", + "string.prototype.trimstart": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz", + "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==", "requires": { - "define-properties": "^1.1.3", - "function-bind": "^1.1.1" + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" } }, "string_decoder": { @@ -5171,9 +5234,9 @@ } }, "tunnel": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz", - "integrity": "sha1-LTeFoVjBdMmhbcLARuxfxfF0IhM=" + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" }, "tunnel-agent": { "version": "0.6.0", @@ -5211,12 +5274,12 @@ "dev": true }, "typed-rest-client": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.7.1.tgz", - "integrity": "sha512-fZRDWFtUp3J2E0jOiCJYZ9LDrYZHpjY95su//ekqXERS7C1qojP6movh7M4JGURJnBuTVsO0g2N4vEoW5o3Djw==", + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.8.3.tgz", + "integrity": "sha512-gJoH7RE3trY77Bf5MNezVV+21O/WMmt9ps7w1bjFyLxrQqDymDWJSDacem1eM6R86zFM0FlE07F8dOupLmKLmQ==", "requires": { "qs": "^6.9.1", - "tunnel": "0.0.4", + "tunnel": "0.0.6", "underscore": "1.8.3" }, "dependencies": { @@ -5242,6 +5305,17 @@ "integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==", "dev": true }, + "unbox-primitive": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", + "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", + "requires": { + "function-bind": "^1.1.1", + "has-bigints": "^1.0.1", + "has-symbols": "^1.0.2", + "which-boxed-primitive": "^1.0.2" + } + }, "underscore": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", @@ -5321,15 +5395,16 @@ "dev": true }, "util": { - "version": "0.12.1", - "resolved": "https://registry.npmjs.org/util/-/util-0.12.1.tgz", - "integrity": "sha512-MREAtYOp+GTt9/+kwf00IYoHZyjM8VU4aVrkzUlejyqaIjd2GztVl5V9hGXKlvBKE3gENn/FMfHE5v6hElXGcQ==", + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.12.3.tgz", + "integrity": "sha512-I8XkoQwE+fPQEhy9v012V+TSdH2kp9ts29i20TaaDUXsg7x/onePbhFJUExBfv/2ay1ZOp/Vsm3nDlmnFGSAog==", "requires": { "inherits": "^2.0.3", "is-arguments": "^1.0.4", "is-generator-function": "^1.0.7", - "object.entries": "^1.1.0", - "safe-buffer": "^5.1.2" + "is-typed-array": "^1.1.3", + "safe-buffer": "^5.1.2", + "which-typed-array": "^1.1.2" } }, "util-deprecate": { @@ -5452,12 +5527,38 @@ "isexe": "^2.0.0" } }, + "which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "requires": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + } + }, "which-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, + "which-typed-array": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.4.tgz", + "integrity": "sha512-49E0SpUe90cjpoc7BOJwyPHRqSAd12c10Qm2amdEZrJPCY2NDxaW01zHITrem+rnETY3dwrbH3UUrUwagfCYDA==", + "requires": { + "available-typed-arrays": "^1.0.2", + "call-bind": "^1.0.0", + "es-abstract": "^1.18.0-next.1", + "foreach": "^2.0.5", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.1", + "is-typed-array": "^1.1.3" + } + }, "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", @@ -5539,9 +5640,9 @@ "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" }, "y18n": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", + "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", "dev": true }, "yargs": { diff --git a/package.json b/package.json index 460d79cca..2517872c4 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "dependencies": { "@actions/core": "^1.2.6", "actions-secret-parser": "^1.0.3", - "azure-actions-appservice-rest": "^1.3.0", + "azure-actions-appservice-rest": "^1.3.1", "azure-actions-utility": "^1.0.3", "azure-actions-webclient": "^1.1.0" } diff --git a/src/ActionInputValidator/Validations.ts b/src/ActionInputValidator/Validations.ts index 8f4ccd207..e637b620e 100644 --- a/src/ActionInputValidator/Validations.ts +++ b/src/ActionInputValidator/Validations.ts @@ -26,12 +26,12 @@ export function validateAppDetails() { let actionParams: ActionParameters = ActionParameters.getActionParams(); - if(!!actionParams.appName || (!!actionParams.slotName && actionParams.slotName !== 'production')) { + if(!!actionParams.appName || (!!actionParams.slotName && actionParams.slotName.toLowerCase() !== 'production')) { let creds: ScmCredentials = PublishProfile.getPublishProfile(actionParams.publishProfileContent).creds; //for kubeapps in publishsettings file username doesn't start with $, for all other apps it starts with $ let splitUsername: string[] = creds.username.startsWith("$") ? creds.username.toUpperCase().substring(1).split("__") : creds.username.toUpperCase().split("__"); let appNameMatch: boolean = !actionParams.appName || actionParams.appName.toUpperCase() === splitUsername[0]; - let slotNameMatch: boolean = actionParams.slotName === 'production' || actionParams.slotName.toUpperCase() === splitUsername[1]; + let slotNameMatch: boolean = actionParams.slotName.toLowerCase() === 'production' || actionParams.slotName.toUpperCase() === splitUsername[1]; if(!appNameMatch || !slotNameMatch) { throw new Error("Publish profile is invalid for app-name and slot-name provided. Provide correct publish profile credentials for app."); } @@ -55,7 +55,7 @@ export function packageNotAllowed(apppackage: string) { // Error if multi container config file is provided export function multiContainerNotAllowed(configFile: string) { if(!!configFile) { - throw new Error("Multi container support is not available for windows containerized web app."); + throw new Error("Multi container support is not available for windows containerized web app or with publish profile."); } } @@ -71,10 +71,10 @@ export function validateSingleContainerInputs() { export function validateContainerInputs() { let actionParams: ActionParameters = ActionParameters.getActionParams(); - + actionParams.isMultiContainer = false; - if(!!actionParams.multiContainerConfigFile && exist(actionParams.multiContainerConfigFile)){ + if(!!actionParams.multiContainerConfigFile && exist(actionParams.multiContainerConfigFile)){ let stats: fs.Stats = fs.statSync(actionParams.multiContainerConfigFile); if(!stats.isFile()) { throw new Error("Docker-compose file path is incorrect."); @@ -103,9 +103,9 @@ export function validateContainerInputs() { export async function validatePackageInput() { let actionParams = ActionParameters.getActionParams(); actionParams.package = new Package(actionParams.packageInput); - + // msbuild package deployment is not supported - let isMSBuildPackage = await actionParams.package.isMSBuildPackage(); + let isMSBuildPackage = await actionParams.package.isMSBuildPackage(); if(isMSBuildPackage) { throw new Error(`Deployment of msBuild generated package is not supported. Please change package format.`); } diff --git a/src/ActionInputValidator/ValidatorFactory.ts b/src/ActionInputValidator/ValidatorFactory.ts index 5b6543be9..ccbfbe9f5 100644 --- a/src/ActionInputValidator/ValidatorFactory.ts +++ b/src/ActionInputValidator/ValidatorFactory.ts @@ -47,7 +47,7 @@ export class ValidatorFactory { } } else { - throw new Error("Valid credentails are not available. Add Azure Login action before this action or provide publish-profile input."); + throw new Error("Valid credentials are not available. Add Azure Login action before this action or provide publish-profile input."); } } @@ -65,4 +65,4 @@ export class ValidatorFactory { const appOS: string = await publishProfile.getAppOS(); actionParams.isLinux = appOS.includes(RuntimeConstants.Unix) || appOS.includes(RuntimeConstants.Unix.toLowerCase()); } -} \ No newline at end of file +} diff --git a/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts b/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts index 4e3518f24..0da14307c 100644 --- a/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts +++ b/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts @@ -5,6 +5,7 @@ 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 { @@ -30,7 +31,7 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider { 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); + this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName }); break; case PackageType.folder: @@ -38,12 +39,12 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider { 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); + 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); + this.deploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, { slotName: this.actionParams.slotName }); break; default: @@ -67,4 +68,13 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider { 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); + } } \ No newline at end of file diff --git a/src/actionparameters.ts b/src/actionparameters.ts index 8a3ba7c76..9310cd335 100644 --- a/src/actionparameters.ts +++ b/src/actionparameters.ts @@ -42,13 +42,14 @@ export class ActionParameters { this._images = core.getInput('images'); this._multiContainerConfigFile = core.getInput('configuration-file'); this._startupCommand = core.getInput('startup-command'); - this._endpoint = endpoint; + this._endpoint = endpoint; } public static getActionParams(endpoint?: IAuthorizer) { - if(!this.actionparams) { + if (!this.actionparams) { this.actionparams = new ActionParameters(!!endpoint ? endpoint : null); } + return this.actionparams; }