Commit 07603e5f authored by Anthony Jacob's avatar Anthony Jacob
Browse files

add autodeploy for demo environment

parent f33fbcf9
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@

stages:
  - publish
  - deploy

publish:
  stage: publish
@@ -33,3 +34,23 @@ publish:
    - echo "Publish Docker image..."
    - docker push $DOCKER_IMAGE_NAME
    - echo "image successfully published."

deploy-dev:
  stage: deploy
  image: ubuntu:24.04
  before_script:
    - apt-get -yq update
    - apt-get -yqq install ssh
    - install -m 600 -D /dev/null ~/.ssh/id_rsa
    - echo "$SSH_KEY" | base64 -d > ~/.ssh/id_rsa
    - cat ~/.ssh/id_rsa
    - ssh-keyscan -p $SSH_PORT -H $SSH_HOST  > ~/.ssh/known_hosts
    - cat ~/.ssh/known_hosts
  script:
    - ssh $SSH_USER@$SSH_HOST -p $SSH_PORT "docker service update --force --image $DOCKER_IMAGE_NAME stack_wwwdemo_www"
  after_script:
    - rm -rf ~/.ssh
  rules:
    - if: $CI_COMMIT_BRANCH == "main"

  environment: Development