-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathsync-docs.sh
executable file
·57 lines (47 loc) · 1.38 KB
/
sync-docs.sh
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
56
57
#!/bin/bash
set -e
BRANCH="$1"
VERSION="$2"
if [ -z "$BRANCH" ]; then
BRANCH="master"
fi
if [ -z "$VERSION" ]; then
VERSION="5.0"
fi
KARMA_REPO="karma"
DOCS_REPO=$(cd "$(dirname "$0")"; pwd)
# get latest Karma repo and switch to requested branch or tag
if [ -d "$KARMA_REPO" ]; then
echo "Fetching karma-runner/karma repository updates..."
cd $KARMA_REPO
git fetch
else
echo "Cloning karma-runner/karma repository..."
git clone https://github.com/karma-runner/karma.git
cd $KARMA_REPO
fi
echo "Switching karma-runner/karma repository to $BRANCH..."
git checkout --detach $BRANCH
cd $DOCS_REPO
# copy the docs source
echo "Removing old docs..."
rm -rf src/content/$VERSION
echo "Copying the docs from master repo..."
mkdir src/content/$VERSION
cp -r $KARMA_REPO/docs/* $DOCS_REPO/src/content/$VERSION/
echo "Copying the changelog..."
echo -e "---\neditButton: false\n---\n" > $DOCS_REPO/src/content/$VERSION/about/02-changelog.md
cat $KARMA_REPO/CHANGELOG.md >> $DOCS_REPO/src/content/$VERSION/about/02-changelog.md
if test -z "$(git status --porcelain)"; then
echo "Documentation has not changed. Exiting..."
else
echo "Documentation has changed. Updating..."
# commit sync
cd $DOCS_REPO
git add src/content/$VERSION/**/*.md src/content/$VERSION/*.md
git commit -m "Sync the docs"
# build html and commit
./node_modules/.bin/grunt build
git add .
git commit -m "Build"
fi