title: Gitlab-ci and deploy.sh
body: <p>I'm trying to use the continuous integration system that Gitlab CI offers to build skills and automatically deploy my repo following a git push my local.</p>
  
  <p>But here are weeks that I can not find the solutions that I decided to use.</p>
  
  <p>Files :</p>
  
  <ol>
  <li>./.gitlab-ci.yml</li>
  <li>./deploy.sh</li>
  </ol>
  
  <p><strong>gitlab-ci.yml</strong></p>
  
  <pre><code>image: ubuntu:latest
  
  before_script:
    - apt-get install -y
    - apt-get update -y
  
  stages:
    - deploy
  
  deploy_staging:
    stage: deploy
    script:
      - echo "Deploy to staging server"
      - expect ./deploy.sh
    environment:
      name: staging
      url: my.site.com
    only:
    - master
  </code></pre>
  
  <p><strong>deploy.sh</strong></p>
  
  <pre><code>#!/usr/bin/expect -f
  
  spawn ssh username@host "cd www &amp;&amp; git pull https://Username:myPassword@gitlab.com/My/privaterepo.git"
  
  expect "password:"
  send "myPassword\n";
  
  interact
  </code></pre>
  
  <p>My problem is that I often have an error like this :</p>
  
  <pre><code>- expect ./deploy.sh
  /bin/bash: line 79: expect: command not found
  </code></pre>
  
  <p>I had other errors when I enter my sh file from gitlab-ci.yml :</p>
  
  <pre><code>- sh ./deploy.sh ( or bash ./deploy.sh )
  ./deploy.sh: 6: ./deploy.sh: spawn: not found
  ./deploy.sh: 8: ./deploy.sh: expect: not found
  ./deploy.sh: 9: ./deploy.sh: send: not found
  ./deploy.sh: 11: ./deploy.sh: interact: not found
  </code></pre>
  
  <p>and when in my terminal of my computer I run expect ./deploy.sh, the deployment is working properly.</p>
  
  <p>i also tried in the before_script to install expect :</p>
  
  <pre><code>- apt-get update expect -y
  </code></pre>
  
  <p>But I had a question for one package "tzdata" to choose my country. but I can not intervene in the script.</p>
  
  <p>My goal is that every git push of my local, that gitlab it launches a git pull and the update of the code on my site of preprod and prod then (that I intend to block then with a "when : manual "in another task).</p>
  
  <p>Would you have a solution to help me solve this problem because I think it does not take a lot of things that I do not understand ?</p>
  
  <p>Thank you !</p>