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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
41 changes: 5 additions & 36 deletions lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
break;
case packageUtility_1.PackageType.folder:
let tempPackagePath = utility.generateTemporaryFolderOrZipPath(`${process.env.RUNNER_TEMP}`, false);
// excluding release.zip while creating zip for deployment if it's a Linux PHP app
yield this.deleteReleaseZipForLinuxPhpApps(webPackage);
// Excluding release.zip while creating zip for deployment if it's a Linux app
yield this.deleteReleaseZipForLinuxApps(webPackage);
webPackage = (yield zipUtility.archiveFolder(webPackage, "", tempPackagePath));
core.debug("Compressed folder into zip " + webPackage);
core.debug("Initiated deployment via kudu service for webapp package : " + webPackage);
Expand Down Expand Up @@ -124,58 +124,27 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
core.setOutput('webapp-url', this.applicationURL);
});
}
deleteReleaseZipForLinuxPhpApps(webPackage) {
deleteReleaseZipForLinuxApps(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');
// Check if release.zip exists
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
try {
yield fs_1.default.promises.unlink(releaseZipPath);
core.debug(`Deleted release.zip`);
}
catch (error) {
core.debug(`Error while deleting release.zip for Linux PHP app: ${error}`);
}
});
}
checkIfTheAppIsPhpApp(webPackage) {
return __awaiter(this, void 0, void 0, function* () {
try {
// 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
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) {
core.debug(`Error while checking if the app is PHP: ${error}`);
core.debug(`Error while deleting release.zip for Linux app: ${error}`);
}
return false;
});
}
}
Expand Down
Loading
Loading