title: Gitlab-ci: pushing a repo from Gitlab to the Gitlab Runner host?
body: <p>I am using gitlab-ci to deploy some Docker stack files on a couple of remote servers. It works great to build the image, push to the registry, and then pull and deploy.</p>
  
  <p>However, I am somehow getting stuck with a much simpler use case - I just want to have my repository on gitlab to be pushed to a folder on the remote server. Currently, I have a cron job doing a git pull every 5 minutes, but I would rather have this in a gitlab-ci file so I can eventually add some tests, etc.</p>
  
  <p>Here is my current attempt. I have tried a bunch of variations at this point though.</p>
  
  <pre><code> deploy:
    stage: deploy
    only:
      - master
    script:
      - apk update &amp;&amp; apk add git
      - echo $CI_PROJECT_DIR
      - if [ ! -d .git ] ; then git clone ${CI_REPOSITORY_URL} . ; else echo "Respository already cloned" ; fi
      - git remote set-url origin ${CI_REPOSITORY_URL}
      - git pull origin ${CI_COMMIT_REF_NAME}
      - git reset --hard ${CI_COMMIT_SHA}
      - git submodule init
      - git submodule update
      - git reset --hard --recurse-submodule HEAD
      - git clean -f
      - git submodule foreach --recursive git clean -f
      - ls $CI_PROJECT_DIR ; echo
  </code></pre>
  
  <p>And my config:</p>
  
  <pre><code> [[runners]]
    name = "Docker Runner"
    url = "https://gitlab.com/"
    token = ""
    executor = "docker"
    [runners.custom_build_dir]
    [runners.docker]
      tls_verify = false
      image = "docker:latest"
      privileged = false
      disable_entrypoint_overwrite = false
      oom_kill_disable = false
      disable_cache = false
      volumes = ["/var/run/docker.sock:/var/run/docker.sock",
                 "/mnt/airflow/dags:/builds",
                 "/cache"]
      shm_size = 0
    [runners.cache]
      [runners.cache.s3]
      [runners.cache.gcs]
  </code></pre>
  
  <p>My code is being added in the /mnt/airflow/dags directory on the host, but it has a few subfolders I want to get rid of (the full path is /dags/runner_id/0/project_name/project). My goal is to just have the path be /mnt/airflow/dags/project.</p>
  
  <p>I tried using a Shell executor as well, but since my gitlab Runner is a docker container, it was just adding the data inside the container and I did not see an example of mounting a volume to the host.</p>