diff --git a/__tests__/git.test.ts b/__tests__/git.test.ts index 9aba5c36c..fb3d210e5 100644 --- a/__tests__/git.test.ts +++ b/__tests__/git.test.ts @@ -469,5 +469,38 @@ describe('git', () => { expect(execute).toHaveBeenCalledTimes(17) expect(response).toBe(Status.SUCCESS) }) + + it('should silently handle chmod failures on read-only folders', async () => { + let chmodCallCount = 0 + ;(execute as jest.Mock).mockImplementation((cmd: string) => { + // Simulate chmod failures for read-only folders + if (cmd.includes('chmod -R +rw')) { + chmodCallCount++ + throw new Error('Operation not permitted') + } + return {stdout: '', stderr: ''} + }) + + Object.assign(action, { + hostname: 'github.com', + silent: false, + folder: 'assets', + branch: 'branch', + token: '123', + repositoryName: 'JamesIves/montezuma', + pusher: { + name: 'asd', + email: 'as@cat' + }, + isTest: TestFlag.HAS_CHANGED_FILES + }) + + const response = await deploy(action) + + // Verify that chmod was attempted twice (once for folderPath, once for temporaryDeploymentDirectory) + expect(chmodCallCount).toBe(2) + // Verify deployment still succeeds despite chmod failures + expect(response).toBe(Status.SUCCESS) + }) }) }) diff --git a/src/git.ts b/src/git.ts index 248db032a..c754de21e 100644 --- a/src/git.ts +++ b/src/git.ts @@ -145,10 +145,10 @@ export async function deploy(action: ActionInterface): Promise { await execute( `chmod -R +rw ${action.folderPath}`, action.workspace, - action.silent + true // Always silent to avoid flooding output on read-only folders ) } catch { - info(`Unable to modify permissions…`) + // Silently ignore chmod failures - they are non-critical and often occur with read-only folders } // Ensures that items that need to be excluded from the clean job get parsed. @@ -368,11 +368,15 @@ export async function deploy(action: ActionInterface): Promise { action.silent ) - await execute( - `chmod -R +rw ${temporaryDeploymentDirectory}`, - action.workspace, - action.silent - ) + try { + await execute( + `chmod -R +rw ${temporaryDeploymentDirectory}`, + action.workspace, + true // Always silent to avoid flooding output on read-only folders + ) + } catch { + // Silently ignore chmod failures - they are non-critical and often occur with read-only folders + } await execute( `git worktree remove ${temporaryDeploymentDirectory} --force`,