.gitlab-ci.yml 2.18 KB
Newer Older
Andreas Böttger's avatar
Andreas Böttger committed
1 2 3 4 5 6 7 8 9 10 11 12
variables:
    REVIEW_IMAGE: docker.rz.tu-harburg.de:5000/docker/jekyll
    DOCKER_CONTAINER_NAME: ${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG}

stages:
    - review
    - deploy
    
review:start:
    stage: review
    script:
        - pwd
Alexander Lehning's avatar
Alexander Lehning committed
13
        - sudo docker run --detach --rm --env VIRTUAL_HOST=${CI_ENVIRONMENT_SLUG} --name ${DOCKER_CONTAINER_NAME} ${REVIEW_IMAGE}:latest || true
Andreas Böttger's avatar
Andreas Böttger committed
14 15 16 17 18 19 20 21 22 23 24 25
        - 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
26 27
    except:
        - master
Andreas Böttger's avatar
Andreas Böttger committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

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
44 45 46
    except:
        - master
        
Andreas Böttger's avatar
Andreas Böttger committed
47
deploy:generate:
Andreas Böttger's avatar
Andreas Böttger committed
48 49 50 51 52 53 54
    stage: deploy
    only:
        - master
    tags:
        - production
    script:
        - sudo docker pull docker.rz.tu-harburg.de:5000/docker/jekyll-glr:latest
Andreas Böttger's avatar
Andreas Böttger committed
55
        - 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
56
        - 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
57 58 59 60 61 62 63

    artifacts:
        name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
        paths:
            # Was hier nicht gelistet ist, landet auch nicht in der `review`-Phase
            - _site

Andreas Böttger's avatar
Andreas Böttger committed
64
deploy:deploy:
Andreas Böttger's avatar
Andreas Böttger committed
65 66 67 68 69
    stage: deploy
    only:
        - master
    tags:
        - production
Andreas Böttger's avatar
Andreas Böttger committed
70
    when: manual
Andreas Böttger's avatar
Andreas Böttger committed
71 72 73 74 75 76 77
    script:
        - pwd
        - 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
        url: https://$PROXY_HOST_NAME/$CI_PROJECT_PATH/