.gitlab-ci.yml 1.78 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
        - 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
Andreas Böttger's avatar
Andreas Böttger committed
21 22 23 24 25 26
    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
27 28 29 30 31
    only:
        - branches
    tags:
        - development
        - ssg
Andreas Böttger's avatar
Andreas Böttger committed
32 33
#    except:
#        - master
Andreas Böttger's avatar
Andreas Böttger committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

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
50 51
#    except:
#        - master
Andreas Böttger's avatar
Andreas Böttger committed
52
    
Andreas Böttger's avatar
Andreas Böttger committed
53
    
Andreas Böttger's avatar
Andreas Böttger committed
54 55 56 57 58 59
deploy:
    stage: deploy
    only:
        - master
    tags:
        - production
Andreas Böttger's avatar
Andreas Böttger committed
60
    when: manual
Andreas Böttger's avatar
Andreas Böttger committed
61 62 63 64 65 66 67
    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/