-
Notifications
You must be signed in to change notification settings - Fork 9
/
push.sh
58 lines (44 loc) · 1.48 KB
/
push.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
58
#!/bin/bash
# ----------------------------------------------------------
# Automatically push back the generated JavaDocs to gh-pages
# ----------------------------------------------------------
# based on https://gist.github.com/willprice/e07efd73fb7f13f917ea
# specify the common address for the repository
targetRepo=github.com/akarnokd/ixjava.git
# =======================================================================
# only for main pushes, for now
if [ "$CI_PULL_REQUEST" == "true" ]; then
echo -e "Pull request detected, skipping JavaDocs pushback."
exit 0
fi
# check if the token is actually there
if [ "$JAVADOCS_TOKEN" == "" ]; then
echo -e "No access to GitHub, skipping JavaDocs pushback."
exit 0
fi
# prepare the git information
git config --global user.email "akarnokd@gmail.com"
git config --global user.name "akarnokd"
# setup the remote
git remote add origin-pages https://${JAVADOCS_TOKEN}@${targetRepo} > /dev/null 2>&1
# stash changes due to chmod
git stash
# get the gh-pages
git fetch --all
git branch -a
git checkout -b gh-pages origin-pages/gh-pages
# remove old dir
rm -rf javadoc
# copy and overwrite new doc
yes | cp -rfv ./build/docs/javadoc/ javadoc/
# stage all changed and new files
git add --all --verbose
#git add *.html --verbose
#git add *.css --verbose
#git add *.js --verbose
#git add javadoc/package-list --verbose
# commit all
git commit --message "CI build: $CI_BUILD_NUMBER"
# push it
git push --quiet --set-upstream origin-pages gh-pages
# we are done