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
33 changes: 33 additions & 0 deletions __tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})
18 changes: 11 additions & 7 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ export async function deploy(action: ActionInterface): Promise<Status> {
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.
Expand Down Expand Up @@ -368,11 +368,15 @@ export async function deploy(action: ActionInterface): Promise<Status> {
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`,
Expand Down