I have a simple way to deploy a Phoenix/Elixir which is: login onto a server ssh, compile a project via mix, build a release and restart a project. Everything works well. However, once I’ve tried to automate the process, I’ve discovered:
#!/bin/bash # Step a: Connect to the server via SSH ssh email@example.com << 'EOF' cd /usr/local/web/pr1 git pull origin master -f if [ -z "$(git diff --check)" ]; then echo "No conflicts detected" else echo "Conflicts detected, please resolve before continuing" exit 1 fi export $(cat config/.env.prod | xargs) # ok echo "**debug #0" # (!) this won't pass this command mix compile --force # no errors, but this will never get executed echo "**debug #1" # Step g: Check for errors if [ $? -eq 0 ]; then echo "No errors detected" # ......... echo "done" else echo "Errors occurred during custom tool execution" exit 1 fi EOF
A script will always stop after the command
mix compile has run. No errors, no compilation ones either! I’d do it manually and it’d work!
As if there was a signalt the
mix compile --force would send to the terminal or ssh connection exit the process.
What’s the matter?