currently I use this code to deploy my application:
script: - | ssh email@example.com /bin/bash -s << EOT cd code TIMESTAMP=\$(date +%Y-%m-%d_%H-%M-%S) DEPLOY_DIR="releases/\$TIMESTAMP" mkdir -p "\$DEPLOY_DIR" tar -xzvf code.tar.gz -C "\$DEPLOY_DIR" && rm code.tar.gz sudo /usr/sbin/service webapp stop ln -snf "\$DEPLOY_DIR" current ./current/bin/webapp migrate ./current/bin/webapp seed sudo /usr/sbin/service webapp start EOT
But this has a few problems:
- Within the runner logs in the gitlab interface I only see:
collapsed multi-line command
- If one of the commands fails with an non 0 exit code the gitlab runner still marks that deployment as successful
How can this be improved to see everything in the logs and fail properly if something goes wrong within the ssh commands?