/
docs
executable file
·55 lines (43 loc) · 1.37 KB
/
docs
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
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
set -e
BRANCH='master'
BUILD_DIR='build/'
REPOSITORY=`mktemp -d /tmp/reactstrap.XXXXXX`
GITHUB_REPO='reactstrap/reactstrap.github.io'
success() {
echo -e "\033[32;1m$1"
}
error() {
echo -e "\033[31;1m$1"
}
if [ "$TRAVIS_BRANCH" == "$TRAVIS_TAG" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo "Deploying documentation"
else
success "Not building master branch. Skipping deploy."
exit 0
fi
if [ -z "$GITHUB_TOKEN" ]; then
error "Environment variable GITHUB_TOKEN does not exist. Stopping deploy."
exit 1
fi
npm run build:docs
if [ ! -d $BUILD_DIR ]; then
error "Build directory does not exist. Stopping deploy."
exit 1
fi
echo "Cloning ${GITHUB_REPO} & applying changes"
git clone --branch $BRANCH https://${GITHUB_TOKEN}@github.com/${GITHUB_REPO}.git $REPOSITORY > /dev/null 2>&1
rsync -rt --del --exclude=".git" $BUILD_DIR $REPOSITORY
cd $REPOSITORY
if [ -z "$(git status --porcelain)" ]; then
success "No documentation changes to publish. Skipping deploy."
exit 0
fi
git config user.name "Travis-CI"
git config user.email "reactstrap@github.io"
git add --all
git commit -m "docs(travis): publish documentation for $TRAVIS_TAG ($TRAVIS_COMMIT)"
git push origin $BRANCH > /dev/null 2>&1
git tag -a $VERSION -m "docs $TRAVIS_TAG"
git push --tags > /dev/null 2>&1
success "Successfully published documentation for $TRAVIS_TAG ($TRAVIS_COMMIT)!"