-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathpublish-gh-pages-inside-docker.sh
executable file
·59 lines (53 loc) · 1.73 KB
/
publish-gh-pages-inside-docker.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
59
#!/bin/bash
# DO NOT USE
# OR RATHER READ IT AND THEN USE
# ONLY WORKS FROM THE PROJECT DIR
# WILL PUBLISH STUFF ON THE WEBSITE, DON'T SCREW UP
BUILD_DIR="gh-pages"
echo "BUILD_DIR->${BUILD_DIR}"
OLD=${PWD}
echo "OLD->${OLD}"
ORIGIN_URL=$(git config --get remote.origin.url)
echo "ORIGIN_URL->${ORIGIN_URL}"
echo "->${PWD}/build-html-docker-inside-docker.sh"
${PWD}/build-html-docker-inside-docker.sh
#echo "*******************************"
#ls -lah ${OLD}/${BUILD_DIR}
#echo "*******************************"
#exit 0
cd $BUILD_DIR
echo "GIT_GLOBAL_MAIL->${GIT_GLOBAL_MAIL}"
echo "GIT_GLOBAL_USER_NAME->${GIT_GLOBAL_USER_NAME}"
git config --global user.email ${GIT_GLOBAL_MAIL}
git config --global user.name ${GIT_GLOBAL_USER_NAME}
git init
git add .
git commit -m "$GIT_GLOBAL_USER_NAME - rebuilding gh-pages $(date)"
# rename branch to 'main' if necessary
CURRENT_BRANCH=$(git branch --show-current)
echo "current branch: $CURRENT_BRANCH"
if [ "$CURRENT_BRANCH" != "main" ]
then
git branch -M main
echo "branch $CURRENT_BRANCH renamed to 'main'"
else
echo "branch $CURRENT_BRANCH not renamed"
fi
git remote add origin $ORIGIN_URL
# echo gh-pages url
IFS='/' read -ra TEMP <<< "$ORIGIN_URL"
#for i in "${TEMP[@]}"; do
# # process "$i"
# echo "$i"
#done
REPO_NAME=${TEMP[4]}
echo
echo "***********************************************************"
echo trying to create gh-pages under following url
echo https://${TEMP[3]}.github.io/${REPO_NAME%.*}
echo "***********************************************************"
# Sources:
# https://stackoverflow.com/a/965072
# https://stackoverflow.com/a/918931
# maybe better with subtrees -> https://gist.github.com/cobyism/4730490
# https://blog.bloomca.me/2017/12/15/how-to-push-folder-to-github-pages.html