@@ -54,6 +54,7 @@ const BaseWebAppDeploymentProvider_1 = require("./BaseWebAppDeploymentProvider")
5454const AnnotationUtility_1 = require ( "azure-actions-appservice-rest/Utilities/AnnotationUtility" ) ;
5555const promises_1 = require ( "fs/promises" ) ;
5656const path_1 = __importDefault ( require ( "path" ) ) ;
57+ const fs = __importStar ( require ( "fs" ) ) ;
5758class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1 . BaseWebAppDeploymentProvider {
5859 DeployWebAppStep ( ) {
5960 return __awaiter ( this , void 0 , void 0 , function * ( ) {
@@ -81,18 +82,7 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
8182 case packageUtility_1 . PackageType . folder :
8283 let tempPackagePath = utility . generateTemporaryFolderOrZipPath ( `${ process . env . RUNNER_TEMP } ` , false ) ;
8384 const releaseZipPath = path_1 . default . join ( webPackage , 'release.zip' ) ;
84- try {
85- yield ( 0 , promises_1 . unlink ) ( releaseZipPath ) ;
86- core . info ( `Deleted: ${ releaseZipPath } ` ) ;
87- }
88- catch ( err ) {
89- if ( err . code === 'ENOENT' ) {
90- core . error ( `File does not exist: ${ releaseZipPath } ` ) ;
91- }
92- else {
93- core . error ( `Error while deleting file ${ releaseZipPath } , Error: ${ err } ` ) ;
94- }
95- }
85+ yield this . deleteReleaseZip ( webPackage ) ;
9686 webPackage = ( yield zipUtility . archiveFolder ( webPackage , "" , tempPackagePath ) ) ;
9787 core . debug ( "Compressed folder into zip " + webPackage ) ;
9888 core . debug ( "Initiated deployment via kudu service for webapp package : " + webPackage ) ;
@@ -135,5 +125,46 @@ class WebAppDeploymentProvider extends BaseWebAppDeploymentProvider_1.BaseWebApp
135125 core . setOutput ( 'webapp-url' , this . applicationURL ) ;
136126 } ) ;
137127 }
128+ deleteReleaseZip ( folderPath ) {
129+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
130+ let isPhpApp = yield this . containsPhpFiles ( folderPath ) ;
131+ if ( ! isPhpApp ) {
132+ core . info ( "No PHP files found in the folder, skipping release.zip deletion." ) ;
133+ return ;
134+ }
135+ let releaseZipPath = path_1 . default . join ( folderPath , 'release.zip' ) ;
136+ try {
137+ yield ( 0 , promises_1 . unlink ) ( releaseZipPath ) ;
138+ core . info ( `Deleted: ${ releaseZipPath } ` ) ;
139+ }
140+ catch ( err ) {
141+ if ( err . code === 'ENOENT' ) {
142+ core . error ( `File does not exist: ${ releaseZipPath } ` ) ;
143+ }
144+ else {
145+ core . error ( `Error while deleting file ${ releaseZipPath } , Error: ${ err } ` ) ;
146+ }
147+ }
148+ } ) ;
149+ }
150+ containsPhpFiles ( directoryPath ) {
151+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
152+ try {
153+ const files = fs . readdirSync ( directoryPath ) ;
154+ for ( const file of files ) {
155+ const fullPath = path_1 . default . join ( directoryPath , file ) ;
156+ const stat = fs . statSync ( fullPath ) ;
157+ if ( stat . isFile ( ) && path_1 . default . extname ( file ) . toLowerCase ( ) === '.php' ) {
158+ return true ;
159+ }
160+ }
161+ return false ;
162+ }
163+ catch ( error ) {
164+ console . error ( `Error checking directory: ${ error . message } ` ) ;
165+ return false ;
166+ }
167+ } ) ;
168+ }
138169}
139170exports . WebAppDeploymentProvider = WebAppDeploymentProvider ;
0 commit comments