.gitlab-ci.yml 3.43 KB
Newer Older
Axel Dürkop's avatar
Axel Dürkop committed
1 2 3 4 5 6 7 8
variables:
    COLON: ':'

stages:
    - build
    - review
    - deploy

9
build_pandoc:
Axel Dürkop's avatar
Axel Dürkop committed
10 11 12 13 14 15 16
    stage: build
    only:
        - branches
    tags:
        - development
    script:
        - pwd
17
        - sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/pandoc4gitbook
18
        - mkdir -p book_pdf; sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/pandoc .pandoc-config.yml book.md -o book_pdf/pandocbook.pdf --template=gitbook.latex --latex-engine=xelatex
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
        - sudo chown -R gitlab-runner:gitlab-runner $HOME

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


build_gitbook:
    stage: build
    only:
        - branches
    tags:
        - development
    script:
        - pwd
        #- gitbook install
        #- gitbook build
Axel Dürkop's avatar
Axel Dürkop committed
38
        # Quick and dirty hack: The creation of the PDF document does not always work. This seems to be a bug.
39 40 41 42 43
        #- mkdir -p book_pdf; until gitbook pdf ./ ./book_pdf/book.pdf; do printf "$s\n" "failure, next try …"; done
        - sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/gitbook install
        - sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/gitbook build
        - mkdir -p book_pdf; sudo docker run --rm -v $(pwd):/source docker.rz.tu-harburg.de:5000/docker/gitbook pdf ./ ./book_pdf/book.pdf
        - sudo chown -R gitlab-runner:gitlab-runner $HOME
Axel Dürkop's avatar
Axel Dürkop committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

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


start_review:
    stage: review
    script:
        - sshpass -p "$SSH_PASSWD" ssh -p "$SSH_PORT" $SSH_USER@$HOST_NAME "mkdir -p /usr/share/nginx/html/review/$CI_COMMIT_REF_NAME"
        - sshpass -p "$SSH_PASSWD" scp -P "$SSH_PORT" -r _book/* $SSH_USER@$HOST_NAME:/usr/share/nginx/html/review/$CI_COMMIT_REF_NAME
        - sshpass -p "$SSH_PASSWD" scp -P "$SSH_PORT" -r book_pdf $SSH_USER@$HOST_NAME:/usr/share/nginx/html/review/${CI_COMMIT_REF_NAME}
    environment:
        name: review/$CI_COMMIT_REF_NAME
        url: http://$HOST_NAME$COLON$HTTP_PORT/review/$CI_COMMIT_REF_NAME/
        #url: https://$PROXY_HOST_NAME/reviews/$CI_PROJECT_PATH/$CI_COMMIT_REF_NAME/
        on_stop: stop_review
    only:
        - branches
    tags:
        - development
    except:
        - master

stop_review:
    stage: review
    variables:
        GIT_STRATEGY: none
    script:
        - sshpass -p "$SSH_PASSWD" ssh -p "$SSH_PORT" $SSH_USER@$HOST_NAME "rm -rf /usr/share/nginx/html/review/$CI_COMMIT_REF_NAME"
    when: manual
    environment:
        name: review/$CI_COMMIT_REF_NAME
        action: stop
    only:
        - branches
    tags:
        - development
    except:
        - master

deploy:
    stage: deploy
    only:
        - master
    tags:
        - production
    script:
        - 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
Andreas Böttger's avatar
Andreas Böttger committed
97
        - sshpass -p "$SSH_PASSWD" scp -P "$SSH_PORT" -r book_pdf $SSH_USER@$HOST_NAME:/usr/share/nginx/html/production
Axel Dürkop's avatar
Axel Dürkop committed
98 99
    environment:
        name: production
Axel Dürkop's avatar
Axel Dürkop committed
100
        url: https://$PROXY_HOST_NAME/$CI_PROJECT_PATH/