aboutsummaryrefslogtreecommitdiff
path: root/ci/after-success.sh
blob: 65ddb90483696143af4f9b75c2127ebd38223664 (plain) (blame)
1
2
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
30
31
32
33
34
35
36
37
38
39
40
41
42
set -euxo pipefail

main() {
    local langs=( en ru )

    rm -f .cargo/config
    cargo doc --features timer-queue

    local td=$(mktemp -d)
    cp -r target/doc $td/api
    mkdir $td/book/
    cp redirect.html $td/book/index.html
    for lang in ${langs[@]}; do
        ( cd book/$lang && mdbook build )
        cp -r book/$lang/book $td/book/$lang
        cp LICENSE-* $td/book/$lang/
    done

    mkdir ghp-import
    curl -Ls https://github.com/davisp/ghp-import/archive/master.tar.gz |
        tar --strip-components 1 -C ghp-import -xz

    ./ghp-import/ghp_import.py $td

    set +x
    git push -fq https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git gh-pages && echo OK

    rm -rf $td
}

# fake Travis variables to be able to run this on a local machine
if [ -z ${TRAVIS_BRANCH-} ]; then
    TRAVIS_BRANCH=master
fi

if [ -z ${TRAVIS_PULL_REQUEST-} ]; then
    TRAVIS_PULL_REQUEST=false
fi

if [ $TRAVIS_BRANCH = master ] && [ $TRAVIS_PULL_REQUEST = false ]; then
    main
fi