Skip to content

Commit 7311eb4

Browse files
Merge pull request #483 from Azure/releases/v2-delete-release-for-all
Release/v2 delete release archive for all linux apps
2 parents e8d44d2 + 551f5f7 commit 7311eb4

File tree

2 files changed

+12
-79
lines changed

2 files changed

+12
-79
lines changed

lib/DeploymentProvider/Providers/WebAppDeploymentProvider.js

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
7777
break;
7878
case packageUtility_1.PackageType.folder:
7979
let tempPackagePath = utility.generateTemporaryFolderOrZipPath(`${process.env.RUNNER_TEMP}`, false);
80-
// excluding release.zip while creating zip for deployment if it's a Linux PHP app
81-
yield this.deleteReleaseZipForLinuxPhpApps(webPackage);
80+
// Excluding release.zip while creating zip for deployment if it's a Linux app
81+
yield this.deleteReleaseZipForLinuxApps(webPackage);
8282
webPackage = (yield zipUtility.archiveFolder(webPackage, "", tempPackagePath));
8383
core.debug("Compressed folder into zip " + webPackage);
8484
core.debug("Initiated deployment via kudu service for webapp package : " + webPackage);
@@ -119,58 +119,27 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
119119
core.setOutput('webapp-url', this.applicationURL);
120120
});
121121
}
122-
deleteReleaseZipForLinuxPhpApps(webPackage) {
122+
deleteReleaseZipForLinuxApps(webPackage) {
123123
return __awaiter(this, void 0, void 0, function* () {
124-
// Ignore if the app is not a Linux app or if release.zip does not exist
124+
// Ignore if the app is not a Linux app
125125
if (!this.actionParams.isLinux) {
126126
core.debug(`It's not a Linux app, skipping deletion of release.zip`);
127127
return;
128128
}
129129
const releaseZipPath = path_1.default.join(webPackage, 'release.zip');
130+
// Check if release.zip exists
130131
if (!fs_1.default.existsSync(releaseZipPath)) {
131132
core.debug(`release.zip does not exist, skipping deletion: ${releaseZipPath}`);
132133
return;
133134
}
134-
let isPhpApp = yield this.checkIfTheAppIsPhpApp(webPackage);
135-
// No need to delete release.zip for non-PHP apps
136-
if (!isPhpApp) {
137-
core.debug(`Not a PHP app, skipping deletion of release.zip: ${releaseZipPath}`);
138-
return;
139-
}
140135
// Delete release.zip if it exists
141136
try {
142137
yield fs_1.default.promises.unlink(releaseZipPath);
143138
core.debug(`Deleted release.zip`);
144139
}
145140
catch (error) {
146-
core.debug(`Error while deleting release.zip for Linux PHP app: ${error}`);
147-
}
148-
});
149-
}
150-
checkIfTheAppIsPhpApp(webPackage) {
151-
return __awaiter(this, void 0, void 0, function* () {
152-
try {
153-
// Check if the webPackage folder contains a composer.json file
154-
const composerFile = 'composer.json';
155-
if (fs_1.default.existsSync(path_1.default.join(webPackage, composerFile))) {
156-
core.debug(`Detected PHP app by presence of ${composerFile}`);
157-
return true;
158-
}
159-
// Check if the webPackage folder contains a .php file
160-
core.debug(`Checking for .php files in the web package directory: ${webPackage}`);
161-
const hasPhpFiles = fs_1.default.readdirSync(webPackage, { withFileTypes: true, recursive: true }).some(file => file.isFile() && file.name.endsWith('.php'));
162-
if (hasPhpFiles) {
163-
core.debug(`Detected PHP app by presence of .php files`);
164-
}
165-
else {
166-
core.debug(`No .php files found in the web package directory.`);
167-
}
168-
return hasPhpFiles;
169-
}
170-
catch (error) {
171-
core.debug(`Error while checking if the app is PHP: ${error}`);
141+
core.debug(`Error while deleting release.zip for Linux app: ${error}`);
172142
}
173-
return false;
174143
});
175144
}
176145
}

src/DeploymentProvider/Providers/WebAppDeploymentProvider.ts

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
4040
case PackageType.folder:
4141
let tempPackagePath = utility.generateTemporaryFolderOrZipPath(`${process.env.RUNNER_TEMP}`, false);
4242

43-
// excluding release.zip while creating zip for deployment if it's a Linux PHP app
44-
await this.deleteReleaseZipForLinuxPhpApps(webPackage);
43+
// Excluding release.zip while creating zip for deployment if it's a Linux app
44+
await this.deleteReleaseZipForLinuxApps(webPackage);
4545

4646
webPackage = await zipUtility.archiveFolder(webPackage, "", tempPackagePath) as string;
4747
core.debug("Compressed folder into zip " + webPackage);
@@ -85,64 +85,28 @@ export class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider {
8585
core.setOutput('webapp-url', this.applicationURL);
8686
}
8787

88-
private async deleteReleaseZipForLinuxPhpApps(webPackage: string): Promise<void> {
88+
private async deleteReleaseZipForLinuxApps(webPackage: string): Promise<void> {
8989

90-
// Ignore if the app is not a Linux app or if release.zip does not exist
90+
// Ignore if the app is not a Linux app
9191
if (!this.actionParams.isLinux) {
9292
core.debug(`It's not a Linux app, skipping deletion of release.zip`);
9393
return;
9494
}
9595

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

98+
// Check if release.zip exists
9899
if (!fs.existsSync(releaseZipPath)) {
99100
core.debug(`release.zip does not exist, skipping deletion: ${releaseZipPath}`);
100101
return;
101102
}
102103

103-
let isPhpApp = await this.checkIfTheAppIsPhpApp(webPackage);
104-
105-
// No need to delete release.zip for non-PHP apps
106-
if (!isPhpApp) {
107-
core.debug(`Not a PHP app, skipping deletion of release.zip: ${releaseZipPath}`);
108-
return;
109-
}
110-
111104
// Delete release.zip if it exists
112105
try {
113106
await fs.promises.unlink(releaseZipPath);
114107
core.debug(`Deleted release.zip`);
115108
} catch (error) {
116-
core.debug(`Error while deleting release.zip for Linux PHP app: ${error}`);
109+
core.debug(`Error while deleting release.zip for Linux app: ${error}`);
117110
}
118111
}
119-
120-
private async checkIfTheAppIsPhpApp(webPackage: string): Promise<boolean> {
121-
122-
try {
123-
// Check if the webPackage folder contains a composer.json file
124-
const composerFile = 'composer.json';
125-
if (fs.existsSync(path.join(webPackage, composerFile))) {
126-
core.debug(`Detected PHP app by presence of ${composerFile}`);
127-
return true;
128-
}
129-
130-
// Check if the webPackage folder contains a .php file
131-
core.debug(`Checking for .php files in the web package directory: ${webPackage}`);
132-
const hasPhpFiles = fs.readdirSync(webPackage, {withFileTypes: true, recursive: true}).some(file => file.isFile() && file.name.endsWith('.php'));
133-
134-
if (hasPhpFiles) {
135-
core.debug(`Detected PHP app by presence of .php files`);
136-
} else {
137-
core.debug(`No .php files found in the web package directory.`);
138-
}
139-
140-
return hasPhpFiles;
141-
} catch (error) {
142-
core.debug(`Error while checking if the app is PHP: ${error}`);
143-
}
144-
145-
return false;
146-
}
147-
148112
}

0 commit comments

Comments
 (0)