improve resiliency and speed of build script
Signed-off-by: Riccardo Iaconelli <riccardo.iaconelli@qredo.com>
diff --git a/asf-site-build.sh b/asf-site-build.sh
index 326fac3..fdeee4f 100755
--- a/asf-site-build.sh
+++ b/asf-site-build.sh
@@ -1,3 +1,10 @@
+# TREEDIRTY=0
+if [[ $(git diff --stat) != '' ]]; then
+ # TREEDIRTY=1
+ echo 'The current tree is dirty, please clean it before running the script'
+ exit
+fi
+
BRANCH=$(git branch | grep '^*' | sed 's/* //' )
if [[ $BRANCH == "master" ]]; then
location=$PWD # get current dir
@@ -6,30 +13,31 @@
printf "\nThis directory should end in ../website: %s\n" $PWD # echo website directory just to be safe
printf "\nThe script is going to build the website now, this make take a few minutes.\n"
npm run build # build website
- # for i in ./*; do
- # echo $i
- # done
- printf "\nThe script will make a temporary directory at /tmp/asf-site-prep/\n" $USER # describe action
- mkdir /tmp/asf-site-prep/ # making temp director
- printf "\nThe script will move the contents of the /build directory to /tmp/asf-site-prep/\n" # describe action
- mv ./build/* /tmp/asf-site-prep/ # copy contents of directory
- printf "\nThe script will make a temporary directory at /tmp/asf-site/ and will clone the asf-site branch into it.\n" # describe action
- mkdir /tmp/asf-site # make directory
- cd /tmp/asf-site # switch directory
- git clone -b asf-site --single-branch https://github.com/apache/incubator-milagro # cloning website
- cd incubator-milagro # into directory
- printf "\nThe script will push the new asf-site branch and begin cleanup.\n\n" # describe action
- git rm -r *
- git commit -m "removing asf-site files"
- cp -R /tmp/asf-site-prep/incubator-milagro\ /* /tmp/asf-site/incubator-milagro/
- git add .
- git commit -m "new asf-site"
- git push origin asf-site
- cd $location
- printf "\nRemoving the /tmp directories.\n\n" # describe action
- rm -rf /tmp/asf-site-prep
- rm -rf /tmp/asf-site
- printf "\nAll done!\n" # describe action
+
+ TEMPDIR=$(mktemp -d)
+ mv ./build/incubator-milagro/* $TEMPDIR # copy contents of directory
+ cd $location
+ BRANCHNAME="asf-build-$(date +%s)"
+ # [[ $TREEDIRTY -eq 1 ]] && git stash
+ git checkout -b $BRANCHNAME origin/asf-site && \
+ rm -rf * && \
+ cp -r $TEMPDIR/* . && \
+ git add . && \
+ git commit -m "update website" && \
+ git checkout master
+ # [[ $TREEDIRTY -eq 1 ]] && git stash pop
+ rm -rf $TEMPDIR
+
+ echo
+ echo "> site built in" $BRANCHNAME
+ echo "> please inspect and potentially push the result"
+ echo
+ echo "git checkout $BRANCHNAME"
+ echo "git checkout asf-site && git merge --fast-forward $BRANCHNAME"
+ echo
+ echo "> when you are done, clean up after yourself:"
+ echo "git branch -d $BRANCHNAME"
+
elif [[ $BRANCH != "master" ]]; then
printf "\nThis script must be run off the master branch.\n"
fi
diff --git a/website/siteConfig.js b/website/siteConfig.js
index 761b720..c09ad4d 100644
--- a/website/siteConfig.js
+++ b/website/siteConfig.js
@@ -31,7 +31,7 @@
// baseUrl: '/test-site/',
// Used for publishing and more
- projectName: 'incubator-milagro ',
+ projectName: 'incubator-milagro',
organizationName: 'apache',
// For top-level user or org sites, the organization is still the same.
// e.g., for the https://JoelMarcey.github.io site, it would be set like...