Commit fc5dc431 authored by Federico Falconieri's avatar Federico Falconieri
Browse files

feat: adds clone job

this job clones a repository on a remote machine through ssh
parent cb5fd92a
Loading
Loading
Loading
Loading

cd/clone.yml

0 → 100644
+18 −0
Original line number Diff line number Diff line
---

clone:
  image: alpine
  stage: deploy
  before_script:
    - apk add openssh
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config'
    - ssh ${REMOTE_USER}@${REMOTE_HOST} "
        git config --global user.email 'cd@bot.com' &&
        git config --global user.name 'cd' &&
        rm -rf ${CI_PROJECT_NAME} || true &&
        git clone --recurse-submodules --branch ${CI_COMMIT_REF_NAME} https://${GITLAB_DEPLOY_TOKEN_USERNAME}:${GITLAB_DEPLOY_TOKEN}@${CI_REPOSITORY_URL} &&
        exit"