-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis_update_ghpages.sh
executable file
·43 lines (33 loc) · 1.13 KB
/
.travis_update_ghpages.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
#!/bin/bash
set -o errexit -o nounset
YELLOW=$'\e[1;33m'
GREEN=$'\e[1;32m'
RED=$'\e[1;31m'
RESET=$'\e[0m'
# Only publish from the main repository's master branch
REPO_NAME="HydraCG/Specifications"
if [ "$TRAVIS_REPO_SLUG" != "$REPO_NAME" ] || [ "$TRAVIS_BRANCH" != "master" ] || [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo -e "${RED}This commit was made against $TRAVIS_BRANCH and not the master. Don't update gh-pages.${RESET}"
exit;
fi
echo -e "${YELLOW}Updating gh-pages...${RESET}"
echo -e "${YELLOW}Generated files in $PWD/drafts/diagram${RESET}"
ls drafts/diagram
# Checkout the gh-pages branch
echo -e "${YELLOW}Cloning and updating GitHub repository${RESET}"
REPO_PATH=$PWD
pushd $HOME
git clone --branch=gh-pages https://${GH_TOKEN}@github.com/$REPO_NAME gh-pages
cd gh-pages
mkdir -p drafts/diagram/
# Update documents
cp -rf $REPO_PATH/drafts/diagram/* drafts/diagram/
# Commit and push latest version
git config user.name "Travis"
git config user.email "[email protected]"
git add -A .
git status
git commit -m "Update to $TRAVIS_COMMIT."
git push -q origin gh-pages
popd
echo -e "${GREEN}Successfully updated gh-pages${RESET}"