Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions lib/ActionInputValidator/ValidatorFactory.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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");
Expand All @@ -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();
}
}
Expand Down
20 changes: 17 additions & 3 deletions lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,20 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
}
deleteReleaseZipForLinuxPhpApps(webPackage) {
return __awaiter(this, void 0, void 0, function* () {
// If the app is not a Linux app, skip the deletion of release.zip
if (!this.actionParams.isLinux) {
core.debug(`It's not a Linux app, skipping deletion of release.zip`);
return;
}
const releaseZipPath = path_1.default.join(webPackage, 'release.zip');
// Ignore if the app is not a Linux app or if release.zip does not exist
if (!this.actionParams.isLinux || !fs_1.default.existsSync(releaseZipPath)) {
if (!fs_1.default.existsSync(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.debug(`Not a PHP app, skipping deletion of release.zip: ${releaseZipPath}`);
return;
}
// Delete release.zip if it exists
Expand All @@ -152,10 +158,18 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
// Check if the web package contains a composer.json file
const composerFile = 'composer.json';
if (fs_1.default.existsSync(path_1.default.join(webPackage, composerFile))) {
core.debug(`Detected PHP app by presence of ${composerFile}`);
return true;
}
// Check if the webPackage folder contains a .php file
const hasPhpFiles = fs_1.default.readdirSync(webPackage).some(file => file.endsWith('.php'));
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.debug(`Detected PHP app by presence of .php files`);
}
else {
core.debug(`No .php files found in the web package directory`);
}
return hasPhpFiles;
}
catch (error) {
Expand Down
12 changes: 6 additions & 6 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@types/node/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@types/node/http.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions node_modules/@types/node/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion node_modules/electron-to-chromium/full-chromium-versions.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion node_modules/electron-to-chromium/full-versions.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/electron-to-chromium/full-versions.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion node_modules/electron-to-chromium/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/ActionInputValidator/ValidatorFactory.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -22,7 +23,13 @@ export class ValidatorFactory {
return new PublishProfileContainerWebAppValidator();
}
else {
return new PublishProfileWebAppValidator();
try {
await this.setResourceDetails(actionParams);
}
catch (error) {
core.warning(`Failed to set resource details: ${error.message}`);
}
return new PublishProfileWebAppValidator();
}
}
else if(type == DEPLOYMENT_PROVIDER_TYPES.SPN) {
Expand Down
21 changes: 18 additions & 3 deletions src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,25 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
}

private async deleteReleaseZipForLinuxPhpApps(webPackage: string): Promise<void> {

// If the app is not a Linux app, skip the deletion of release.zip
if (!this.actionParams.isLinux) {
core.debug(`It's not a Linux app, skipping deletion of release.zip`);
return;
}

const releaseZipPath = path.join(webPackage, 'release.zip');

// Ignore if the app is not a Linux app or if release.zip does not exist
if (!this.actionParams.isLinux || !fs.existsSync(releaseZipPath)) {
if (!fs.existsSync(releaseZipPath)) {
core.debug(`release.zip does not exist, skipping deletion: ${releaseZipPath}`);
return;
}

let isPhpApp = await this.checkIfTheAppIsPhpApp(webPackage);

// No need to delete release.zip for non-PHP apps
if (!isPhpApp) {
core.debug(`Not a PHP app, skipping deletion of release.zip: ${releaseZipPath}`);
return;
}

Expand All @@ -124,11 +131,19 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
// Check if the web package contains a composer.json file
const composerFile = 'composer.json';
if (fs.existsSync(path.join(webPackage, composerFile))) {
core.debug(`Detected PHP app by presence of ${composerFile}`);
return true;
}

// Check if the webPackage folder contains a .php file
const hasPhpFiles = fs.readdirSync(webPackage).some(file => file.endsWith('.php'));
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.debug(`Detected PHP app by presence of .php files`);
} else {
core.debug(`No .php files found in the web package directory`);
}

return hasPhpFiles;
} catch (error) {
Expand Down
Loading