./deploy.sh not working on gitlab ci

docker:latest is based on alpine linux which is very minimalistic and does not have a lot installed by default. For example, ssh is not available out of the box, so if you want to use ssh commands you need to install it first. In your before_script, add:

- apk update && apk add openssh

This is probably related to the fact you are using Docker-in-Docker (docker:dind). Your deploy.sh is requesting /bin/bash as the script executor which is NOT present in that image.

You can test this locally on your computer with Docker:

docker run --rm -it docker:dind bash

It will report an error. So rewrite the first line of deploy.sh to

#!/bin/sh

After fixing that you will run into the problem that the previous answer is addressing: ssh is not installed either. You will need to fix that too!


Thanks. This worked for me by adding bash

before_script:
  - apk update && apk add bash

Let me know if that still doesn't work for you.