V
V
Vladislav2020-07-13 08:50:36
linux
Vladislav, 2020-07-13 08:50:36

How to set up auto-deploy?

5f0bf41c269ce670356522.png

Here is my error.

I added a private key here:
Av4tspojuS4.jpg

and gitlab-ci itself:

before_script:
  - apt-get update -qq
  - apt-get install -qq git
  - 'which ssh-agent || ( apt-get install -qq openssh-client )'
  - eval $(ssh-agent -s)
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
  - mkdir -p ~/.ssh
  - git rm --cached .gitlab-ci.yml
  - ' && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

deploy_staging:
  type: deploy
  environment:
    name: staging
    url: 45.132.18.232
  script:
    - ssh -A [email protected]45.132.18.232 -p 22 "cd /var/www/zverug.ga/public_html && git checkout master && git pull origin master && composer install && exit"
  only:
    - master

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2020-07-13
@Nc_Soft

before_script:
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
    - mkdir -p ~/.ssh
    - ' && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

And do not forget to add the public key from gitlab to /root/.ssh/authorized_keys on the server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question