Commit 8b0289ae authored by Federico Falconieri's avatar Federico Falconieri
Browse files

feat: cd jobs and pipeline

parent fc5dc431
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
---
variables:
  GIT_SUBMODULE_STRATEGY: recursive

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'
  extends: .ssh
  script:
    - 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} &&
        git config --global user.email 'bot@mail.com' &&
        git config --global user.name 'bot' &&
        rm -rf $CI_PROJECT_NAME &&
        git clone --recurse-submodules --branch $CI_COMMIT_REF_NAME https://${DEPLOY_USER}:${DEPLOY_TOKEN}@${CI_SERVER_HOST}/gitlab/${CI_PROJECT_PATH} &&
        exit"

cd/deploy-make.yml

0 → 100644
+5 −0
Original line number Diff line number Diff line
---
deploy:make:
  extends: .ssh
  script:
    - ssh ${REMOTE_USER}@${REMOTE_HOST} "cd $CI_PROJECT_NAME && make $CI_PROJECT_NAME && exit"

cd/docker-login.yml

0 → 100644
+5 −0
Original line number Diff line number Diff line
---
docker:login:
  extends: .ssh
  script:
    - ssh ${REMOTE_USER}@${REMOTE_HOST} "docker login $CI_REGISTRY -u ${DEPLOY_USER} -p ${DEPLOY_TOKEN}"

cd/ssh.yml

0 → 100644
+10 −0
Original line number Diff line number Diff line
---
.ssh:
  image: alpine
  before_script:
    - apk add openssh
    - eval $(ssh-agent -s)
    - echo "$REMOTE_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'

pipelines/cd.yml

0 → 100644
+25 −0
Original line number Diff line number Diff line
---
include:
    - local: "ssh.yml"
    - local: "clone.yml"
    - local: "docker-login.yml"
    - local: "deploy-make.yml"

stages:
    - deliver
    - configure
    - deploy

clone:
    stage: deliver

docker:login:
    stage: configure

deploy:make:
    stage: deploy

.ssh:
  rules:
    - if: '$CI_COMMIT_REF_PROTECTED == "true"'
    - if: $CI_COMMIT_TAG