.gitlab-ci.yml 1.92 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/jekyll:latest
Andreas Böttger's avatar
Andreas Böttger committed
3 4 5 6 7 8 9 10 11 12
    DOCKER_CONTAINER_NAME: ${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG}

stages:
    - review
    - deploy
    
review:start:
    stage: review
    script:
        - pwd
Andreas Böttger's avatar
Andreas Böttger committed
13 14 15
        - whoami
        - sudo docker pull ${REVIEW_IMAGE}
        - 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
16 17 18 19 20 21 22 23 24 25 26 27
        - sudo docker cp . ${DOCKER_CONTAINER_NAME}:/opt/app
        - sudo docker exec ${DOCKER_CONTAINER_NAME} bundle install --gemfile=/opt/app/Gemfile
    #when: manual
    environment:
        name: review/${CI_COMMIT_REF_NAME}
        url: http://${CI_ENVIRONMENT_SLUG}.collaborating.tuhh.de
        on_stop: review:stop
    only:
        - branches
    tags:
        - development
        - ssg
Andreas Böttger's avatar
Andreas Böttger committed
28 29
    except:
        - master
Andreas Böttger's avatar
Andreas Böttger committed
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

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
Andreas Böttger's avatar
Andreas Böttger committed
46 47
    except:
        - master
Andreas Böttger's avatar
Andreas Böttger committed
48 49

deploy:
Andreas Böttger's avatar
Andreas Böttger committed
50 51 52 53 54
    stage: deploy
    only:
        - master
    tags:
        - production
Andreas Böttger's avatar
Andreas Böttger committed
55
    when: manual
Andreas Böttger's avatar
Andreas Böttger committed
56
    script:
Andreas Böttger's avatar
Andreas Böttger committed
57
        - pwd
Andreas Böttger's avatar
Andreas Böttger committed
58
        - sudo docker pull docker.rz.tu-harburg.de:5000/docker/jekyll-glr:latest
Andreas Böttger's avatar
Andreas Böttger committed
59
        - sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/jekyll-glr:latest install
Andreas Böttger's avatar
Andreas Böttger committed
60
        - sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/jekyll-glr:latest build
Andreas Böttger's avatar
Andreas Böttger committed
61 62 63 64
        - 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 _site/* $SSH_USER@$HOST_NAME:/usr/share/nginx/html/production
    environment:
        name: production
Andreas Böttger's avatar
Andreas Böttger committed
65
        url: https://$PROXY_HOST_NAME/