stages:
  - deploy

deploy:
  stage: deploy
  image: alpine:latest
  rules:
    - if: $CI_COMMIT_BRANCH == "main"
  environment:
    name: production
  before_script:
    - apk add --no-cache openssh-client
    - mkdir -p ~/.ssh && chmod 700 ~/.ssh
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
    - chmod 600 ~/.ssh/id_rsa
    - ssh-keyscan -H ssh.cluster110.hosting.ovh.net >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
  script:
    - ssh carysma@ssh.cluster110.hosting.ovh.net "cd /homez.667/carysma/portail-boosty && git pull origin main && bash deploy.sh"
