deployer
deployer copied to clipboard
Keep releases do not work properly
This workaround solved the problem for us. Add to your deploy.php file:
desc('Fix release_log file');
task('fix:release_log', function() {
cd('{{deploy_path}}');
if(test('[ -f .dep/releases_log ]')) {
$releasesLog = implode("\n", array_map(function($line) {
if(json_decode($line) === null) {
$line = str_replace('{ ', '{ "', str_replace(' }', '" }', $line));
$line = str_replace(' : ', '": "', str_replace(' , ', '", "', $line));
}
return $line;
}, explode("\n", run('cat .dep/releases_log'))));
run("echo '" . str_replace("'", "'\\''", $releasesLog) . "' > .dep/releases_log");
}
});
Then, add before('deploy:cleanup', 'fix:release_log'); to fix the log before the cleanup task.
Originally posted by @david-windsock in https://github.com/deployphp/deployer/discussions/3511#discussioncomment-7690796
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
Thanks @antonmedv, I was going to a new issue but let's keep all here. The problem seems to occur only when a deploy is made from Windows to Linux, resulting in an invalid release_log file format. Each line are not properly escaped (resulting in JSON without double quotes) so releases_log skips all invalid releases.
I think the bug was introduced on 7.1.0 release, because prior to january 2023 the release_log seems to be OK.
Pull requests #3569 and #3603 must solve this problem...
Just to keep this updated: #3569 was discarded in favor of #3603, which was merged two weeks ago. Now waiting for a new release...
There is an estimated date for the next release? Thanks!
Will try to release today.
Thanks @antonmedv