Advertisement
vitvayti

slate

Nov 20th, 2024
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.64 KB | None | 0 0
  1. before_script:
  2.   ##
  3.   ## Install ssh-agent if not already installed, it is required by Docker.
  4.   ## (change apt-get to yum if you use an RPM-based image)
  5.   ##
  6.   - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
  7.  
  8.   ##
  9.   ## Run ssh-agent (inside the pull environment)
  10.   ##
  11.   - eval $(ssh-agent -s)
  12.  
  13.   ##
  14.   ## Give the right permissions, otherwise ssh-add will refuse to add files
  15.   ## Add the SSH key stored in SSH_PRIVATE_KEY file type CI/CD variable to the agent store
  16.   ##
  17.   - chmod 400 "$SSH_PRIVATE_KEY"
  18.   - ssh-add "$SSH_PRIVATE_KEY"
  19.  
  20.   ##
  21.   ## Create the SSH directory and give it the right permissions
  22.   ##
  23.   - mkdir -p ~/.ssh
  24.   - chmod 700 ~/.ssh
  25.   - cp "$SSH_CONFIG" ~/.ssh/config
  26.   - chmod 600 ~/.ssh/config
  27.  
  28.   ## debug
  29.   ## Use ssh-keyscan to scan the keys of your private server.
  30.   ## Replace example.com with your private server's domain name. Repeat that
  31.   ## command if you have more than one server to connect to.
  32.   ##
  33.   - ssh-keyscan bastion.moymarketplace.ru >> ~/.ssh/known_hosts
  34.   - chmod 644 ~/.ssh/known_hosts
  35.   #- 'command -v curl >/dev/null || ( apt-get update -y && apt-get install curl -y )'
  36.   #- curl -s ifconfig.me
  37.   #- grep -vE "^$|#" /etc/ssh/ssh_config
  38.   #- grep -vE "^$|#" ~/.ssh/config
  39.  
  40. stages:          # List of stages for jobs, and their order of execution
  41.   - pull
  42.  
  43. pull-job:       # This job runs in the pull stage, which runs first.
  44.   image: debian
  45.   stage: pull
  46.   script:
  47.     - echo "Pull the code..."
  48.     - ssh -v local.docs.moymarketplace.ru "cd /docker/slate && git pull && git log -p -2 && tree"
  49.     - echo "Pull complete."
  50.   only:
  51.     - main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement