.gitlab-ci.yml 2.72 KB
Newer Older
Andreas Böttger's avatar
Andreas Böttger committed
1
variables:
Andreas Böttger's avatar
Andreas Böttger committed
2
    REVIEW_IMAGE: docker.rz.tu-harburg.de:5000/docker/nginx:latest
Andreas Böttger's avatar
Andreas Böttger committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
    DOCKER_CONTAINER_NAME: ${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG}

stages:
    - review
    - deploy
    
pdf:
    stage: review
    only:
        - branches
    when: manual
    retry: 2
    tags:
        - development
    script:
        - pwd
        - sudo docker pull docker.rz.tu-harburg.de:5000/docker/gitbook-glr:latest
        - mkdir -p book_pdf; sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/gitbook-glr pdf ./ ./book_pdf/book.pdf
    artifacts:
        name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
        paths:
            - book_pdf
    
review:start:
    stage: review
    script:
        - pwd
Andreas Böttger's avatar
Andreas Böttger committed
30
        - sudo docker run --detach --rm --env VIRTUAL_HOST=${CI_ENVIRONMENT_SLUG} --name ${DOCKER_CONTAINER_NAME} ${REVIEW_IMAGE} || true
Andreas Böttger's avatar
Andreas Böttger committed
31
        - mkdir -p book_pdf; sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/gitbook-itbh-glr build
Andreas Böttger's avatar
Andreas Böttger committed
32
        - sudo docker cp ./book_pdf/* ${DOCKER_CONTAINER_NAME}:/usr/share/nginx/html
Andreas Böttger's avatar
Andreas Böttger committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
    environment:
        name: review/${CI_COMMIT_REF_NAME}
        url: http://${CI_ENVIRONMENT_SLUG}.collaborating.tuhh.de
        on_stop: review:stop
    only:
        - branches
    tags:
        - development
        - ssg
    except:
        - master

review:stop:
    stage: review
    variables:
        GIT_STRATEGY: none
    script:
        - sudo docker stop ${DOCKER_CONTAINER_NAME}
    when: manual
    environment:
        name: review/${CI_COMMIT_REF_NAME}
        action: stop
    only:
        - branches
    tags:
        - development
        - ssg
    except:
        - master
    
Andreas Böttger's avatar
Andreas Böttger committed
63
.deploy:
Andreas Böttger's avatar
Andreas Böttger committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
    stage: deploy
    only:
        - master
    tags:
        - production
    script:
        - pwd
        - sudo docker pull docker.rz.tu-harburg.de:5000/docker/gitbook-glr:latest
        - sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/gitbook-glr install
        - sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/gitbook-glr build
        - mkdir -p book_pdf; sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/gitbook-glr pdf ./ ./book_pdf/book.pdf
        - sshpass -p "$SSH_PASSWD" ssh -p "$SSH_PORT" $SSH_USER@$HOST_NAME "mkdir -p /usr/share/nginx/html/production"
        - sshpass -p "$SSH_PASSWD" scp -P "$SSH_PORT" -r _book/* $SSH_USER@$HOST_NAME:/usr/share/nginx/html/production
        - sshpass -p "$SSH_PASSWD" scp -P "$SSH_PORT" -r book_pdf $SSH_USER@$HOST_NAME:/usr/share/nginx/html/production
    environment:
        name: production
        #url: http://$HOST_NAME$COLON$HTTP_PORT/production/
        #url: https://$PROXY_HOST_NAME/$BASE_PATH/
        url: https://$PROXY_HOST_NAME/$CI_PROJECT_PATH/