Skip to content

Commit 02ff3a8

Browse files
authored
Merge pull request #1850 from infotroph/deploy-book-if-repo-exists
Deploy book if repo exists
2 parents bda239c + cf83a1b commit 02ff3a8

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

book_source/deploy.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,21 @@ else
3131
fi
3232

3333
#set USER
34-
USER=${TRAVIS_REPO_SLUG%/*}
34+
GH_USER=${TRAVIS_REPO_SLUG%/*}
3535

3636
# configure your name and email if you have not done so
3737
git config --global user.email "[email protected]"
3838
git config --global user.name "TRAVIS-DOC-BUILD"
3939

4040
# Don't deploy if documentation git repo does not exist
41-
if ! ( git ls-remote -h [email protected]:${USER}/pecan-documentation >/dev/null 2>&1); then
42-
echo "Can't find a repository at https://github.com/${USER}/pecan-documentation"
41+
GH_STATUS=$(curl -s -w %{http_code} -I https://github.com/${GH_USER}/pecan-documentation -o /dev/null)
42+
if [[ $GH_STATUS != 200 ]]; then
43+
echo "Can't find a repository at https://github.com/${GH_USER}/pecan-documentation"
4344
echo "Will not render Book."
4445
exit 0
4546
fi
4647

47-
git clone https://${GITHUB_PAT}@github.com/${USER}/pecan-documentation.git book_hosted
48+
git clone https://${GITHUB_PAT}@github.com/${GH_USER}/pecan-documentation.git book_hosted
4849
cd book_hosted
4950

5051
## Check if branch named directory exists

documentation/tutorials/deploy.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ fi
1212
# Clone book_hosted directory if it doesn't exist
1313
if [ ! -d book_hosted ]; then
1414
# Set GitHub user
15-
USER=${TRAVIS_REPO_SLUG%/*}
15+
GH_USER=${TRAVIS_REPO_SLUG%/*}
1616

1717
# Don't deploy if documentation git repo does not exist
18-
if ! ( git ls-remote -h [email protected]:${USER}/pecan-documentation >/dev/null 2>&1); then
19-
echo "Can't find a repository at https://github.com/${USER}/pecan-documentation"
18+
GH_STATUS=$(curl -s -w %{http_code} -I https://github.com/${GH_USER}/pecan-documentation -o /dev/null)
19+
if [[ $GH_STATUS != 200 ]]; then
20+
echo "Can't find a repository at https://github.com/${GH_USER}/pecan-documentation"
2021
echo "Will not render tutorials."
2122
exit 0
2223
fi
@@ -25,7 +26,7 @@ if [ ! -d book_hosted ]; then
2526
git config --global user.email "[email protected]"
2627
git config --global user.name "TRAVIS-DOC-BUILD"
2728

28-
git clone https://${GITHUB_PAT}@github.com/${USER}/pecan-documentation.git book_hosted
29+
git clone https://${GITHUB_PAT}@github.com/${GH_USER}/pecan-documentation.git book_hosted
2930
fi
3031

3132
# Create tutorial directory

0 commit comments

Comments
 (0)