I'm using Deployer and enjoy it.
One thing I haven't figured out how to do yet though is write a log file of my deployments.
I'm attempting to append the commit hash and date to revisions.txt:
task('log_the_deployment', function () {//https://stackoverflow.com/a/4546755/470749
$selectedStage = Deployer::get()->getInput()->getArgument('stage'); //https://github.com/deployphp/deployer/blob/6180366acff3ca5b2ec511a84e671321c02e7af1/recipe/config/hosts.php#L15
runLocally('set -e'); //https://deployer.org/docs/api.html#runlocally
runLocally('commit_short_hash=$(git rev-parse --short HEAD)');
runLocally('commit=$(git log -1 --pretty="%H%n%ci")');
runLocally('commit_hash=$(echo "$commit" | head -1)');
runLocally('commit_date=$(echo "$commit" | head -2 | tail -1)');
runLocally('branch_name=$(git symbolic-ref -q HEAD)');
runLocally('branch_name=${branch_name##refs/heads/}');
runLocally('branch_name=${branch_name:-HEAD}');
runLocally('echo -e "$commit_date ' . $selectedStage . ' $commit_short_hash branch=\'$branch\' $commit_hash" >> releases.txt');//TODO: prepend instead https://stackoverflow.com/questions/10587615/unix-command-to-prepend-text-to-a-file
});
The result should look something like: 2020-01-09 22:07:00 -0500 staging 146f012d branch='master' 146f012d28d866105aa12605cec6f374d45aec75
Unfortunately my task currently writes only this to the file: -e staging branch=''
What am I misunderstanding about Deployer, runLocally, git, or Unix?
And if there is a much better approach to achieve my goal, I'm happy to go down a totally different path.