diff --git a/lib/ActionInputValidator/ValidatorFactory.js b/lib/ActionInputValidator/ValidatorFactory.js index 953923101..d15b01453 100644 --- a/lib/ActionInputValidator/ValidatorFactory.js +++ b/lib/ActionInputValidator/ValidatorFactory.js @@ -1,4 +1,37 @@ "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || (function () { + var ownKeys = function(o) { + ownKeys = Object.getOwnPropertyNames || function (o) { + var ar = []; + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; + return ar; + }; + return ownKeys(o); + }; + return function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); + __setModuleDefault(result, mod); + return result; + }; +})(); 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) { @@ -13,6 +46,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ValidatorFactory = void 0; +const core = __importStar(require("@actions/core")); const actionparameters_1 = require("../actionparameters"); const AzureResourceFilterUtility_1 = require("azure-actions-appservice-rest/Utilities/AzureResourceFilterUtility"); const BaseWebAppDeploymentProvider_1 = require("../DeploymentProvider/Providers/BaseWebAppDeploymentProvider"); @@ -35,6 +69,12 @@ class ValidatorFactory { return new PublishProfileContainerWebAppValidator_1.PublishProfileContainerWebAppValidator(); } else { + try { + yield this.setResourceDetails(actionParams); + } + catch (error) { + core.warning(`Failed to set resource details: ${error.message}`); + } return new PublishProfileWebAppValidator_1.PublishProfileWebAppValidator(); } } diff --git a/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js b/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js index 390d5199f..8b9cfa39a 100644 --- a/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js +++ b/lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js @@ -123,24 +123,24 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp return __awaiter(this, void 0, void 0, function* () { // Ignore if the app is not a Linux app or if release.zip does not exist if (!this.actionParams.isLinux) { - core.info(`It's not a Linux app, skipping deletion of release.zip`); + core.debug(`It's not a Linux app, skipping deletion of release.zip`); return; } const releaseZipPath = path_1.default.join(webPackage, 'release.zip'); if (!fs_1.default.existsSync(releaseZipPath)) { - core.info(`release.zip does not exist, skipping deletion: ${releaseZipPath}`); + core.debug(`release.zip does not exist, skipping deletion: ${releaseZipPath}`); return; } let isPhpApp = yield this.checkIfTheAppIsPhpApp(webPackage); // No need to delete release.zip for non-PHP apps if (!isPhpApp) { - core.info(`Not a PHP app, skipping deletion of release.zip: ${releaseZipPath}`); + core.debug(`Not a PHP app, skipping deletion of release.zip: ${releaseZipPath}`); return; } // Delete release.zip if it exists try { yield fs_1.default.promises.unlink(releaseZipPath); - core.info(`Deleted release.zip`); + core.debug(`Deleted release.zip`); } catch (error) { core.debug(`Error while deleting release.zip for Linux PHP app: ${error}`); @@ -153,22 +153,22 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp // Check if the webPackage folder contains a composer.json file const composerFile = 'composer.json'; if (fs_1.default.existsSync(path_1.default.join(webPackage, composerFile))) { - core.info(`Detected PHP app by presence of ${composerFile}`); + core.debug(`Detected PHP app by presence of ${composerFile}`); return true; } // Check if the webPackage folder contains a .php file - core.info(`Checking for .php files in the web package directory: ${webPackage}`); + core.debug(`Checking for .php files in the web package directory: ${webPackage}`); const hasPhpFiles = fs_1.default.readdirSync(webPackage, { withFileTypes: true, recursive: true }).some(file => file.isFile() && file.name.endsWith('.php')); if (hasPhpFiles) { - core.info(`Detected PHP app by presence of .php files`); + core.debug(`Detected PHP app by presence of .php files`); } else { - core.info(`No .php files found in the web package directory.`); + core.debug(`No .php files found in the web package directory.`); } return hasPhpFiles; } catch (error) { - core.info(`Error while checking if the app is PHP: ${error}`); + core.debug(`Error while checking if the app is PHP: ${error}`); } return false; }); diff --git a/src/ActionInputValidator/ValidatorFactory.ts b/src/ActionInputValidator/ValidatorFactory.ts index 7e0b8b5ca..ccf344b2c 100644 --- a/src/ActionInputValidator/ValidatorFactory.ts +++ b/src/ActionInputValidator/ValidatorFactory.ts @@ -1,3 +1,4 @@ +import * as core from "@actions/core"; import { ActionParameters, WebAppKind, appKindMap } from "../actionparameters"; import { AzureResourceFilterUtility } from "azure-actions-appservice-rest/Utilities/AzureResourceFilterUtility"; @@ -22,6 +23,11 @@ export class ValidatorFactory { return new PublishProfileContainerWebAppValidator(); } else { + try { + await this.setResourceDetails(actionParams); + } catch (error) { + core.warning(`Failed to set resource details: ${error.message}`); + } return new PublishProfileWebAppValidator(); } } diff --git a/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts b/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts index be8baf822..1937ca96d 100644 --- a/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts +++ b/src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts @@ -9,7 +9,6 @@ import { addAnnotation } from 'azure-actions-appservice-rest/Utilities/Annotatio import fs from 'fs'; import path from 'path'; -import { dir } from 'console'; export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider { @@ -90,14 +89,14 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider { // Ignore if the app is not a Linux app or if release.zip does not exist if (!this.actionParams.isLinux) { - core.info(`It's not a Linux app, skipping deletion of release.zip`); + core.debug(`It's not a Linux app, skipping deletion of release.zip`); return; } const releaseZipPath = path.join(webPackage, 'release.zip'); if (!fs.existsSync(releaseZipPath)) { - core.info(`release.zip does not exist, skipping deletion: ${releaseZipPath}`); + core.debug(`release.zip does not exist, skipping deletion: ${releaseZipPath}`); return; } @@ -105,14 +104,14 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider { // No need to delete release.zip for non-PHP apps if (!isPhpApp) { - core.info(`Not a PHP app, skipping deletion of release.zip: ${releaseZipPath}`); + core.debug(`Not a PHP app, skipping deletion of release.zip: ${releaseZipPath}`); return; } // Delete release.zip if it exists try { await fs.promises.unlink(releaseZipPath); - core.info(`Deleted release.zip`); + core.debug(`Deleted release.zip`); } catch (error) { core.debug(`Error while deleting release.zip for Linux PHP app: ${error}`); } @@ -124,23 +123,23 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider { // Check if the webPackage folder contains a composer.json file const composerFile = 'composer.json'; if (fs.existsSync(path.join(webPackage, composerFile))) { - core.info(`Detected PHP app by presence of ${composerFile}`); + core.debug(`Detected PHP app by presence of ${composerFile}`); return true; } // Check if the webPackage folder contains a .php file - core.info(`Checking for .php files in the web package directory: ${webPackage}`); + core.debug(`Checking for .php files in the web package directory: ${webPackage}`); const hasPhpFiles = fs.readdirSync(webPackage, {withFileTypes: true, recursive: true}).some(file => file.isFile() && file.name.endsWith('.php')); if (hasPhpFiles) { - core.info(`Detected PHP app by presence of .php files`); + core.debug(`Detected PHP app by presence of .php files`); } else { - core.info(`No .php files found in the web package directory.`); + core.debug(`No .php files found in the web package directory.`); } return hasPhpFiles; } catch (error) { - core.info(`Error while checking if the app is PHP: ${error}`); + core.debug(`Error while checking if the app is PHP: ${error}`); } return false;