This repository has been archived by the owner on Nov 15, 2022. It is now read-only.
/
publishWebsite.sh
executable file
·118 lines (99 loc) · 3.9 KB
/
publishWebsite.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# start this script manually:
# chmod u+x ./distribution/publish/publishWebsite.sh
# ./distribution/publish/publishWebsite.sh
# it will clone and update the repo in ./concierge-website-tmp
REPO_DIR=./website-update-tmp
if [ "$#" == "0" ] ; then
echo "Usage: publishWebsite {clean | prepare | commit | push}"
echo " clean: clean all generated files"
echo " prepare: clone repo, and update with current website from repo"
echo " manual step: check if all changes are OK"
echo " commit: add all changes files to stages, commit changes"
echo " push: push to origin repo, no review in Gerrit"
exit 1
fi
if [ "$1" == "clean" ] ; then
# cleanup tmp directory
if [ -d $REPO_DIR/concierge ] ; then
echo "Cleanup $REPO_DIR/concierge ..."
rm -rf $REPO_DIR/concierge/*
rm -rf $REPO_DIR/concierge/.git
rmdir $REPO_DIR/concierge
fi
if [ -d $REPO_DIR ] ; then
echo "Cleanup $REPO_DIR ..."
rmdir $REPO_DIR
fi
exit 0
fi
if [ "$1" == "prepare" ] ; then
echo "Generating website..."
(cd distribution ; ../gradlew generateWebsite)
GENERATED_DIR=`pwd`/distribution/build/website
# cleanup tmp directory
if [ -d $REPO_DIR/concierge ] ; then
echo "Cleanup $REPO_DIR/concierge ..."
rm -rf $REPO_DIR/concierge/*
rm -rf $REPO_DIR/concierge/.git
rmdir $REPO_DIR/concierge
fi
mkdir -p $REPO_DIR
cd $REPO_DIR
# checkout current repo
# get credentials, try ~/.gradle/gradle.properties
if [ "$GERRIT_USERNAME" == "" ]; then
if [ -f ~/.gradle/gradle.properties ] ; then
GERRIT_USERNAME=`cat ~/.gradle/gradle.properties | grep "conciergeGerritUsername" | sed -e 's|^conciergeGerritUsername=||g'`
fi
fi
if [ "$GERRIT_PASSWORD" == "" ]; then
if [ -f ~/.gradle/gradle.properties ] ; then
GERRIT_PASSWORD=`cat ~/.gradle/gradle.properties | grep "conciergeGerritPassword" | sed -e 's|^conciergeGerritPassword=||g'`
fi
fi
if [ "$GERRIT_CONFIG_USER_NAME" == "" ] ; then
if [ -f ~/.gradle/gradle.properties ] ; then
GERRIT_CONFIG_USER_NAME=`cat ~/.gradle/gradle.properties | grep "conciergeGerritConfigUserName" | sed -e 's|^conciergeGerritConfigUserName=||g'`
fi
fi
if [ "$GERRIT_CONFIG_USER_EMAIL" == "" ] ; then
if [ -f ~/.gradle/gradle.properties ] ; then
GERRIT_CONFIG_USER_EMAIL=`cat ~/.gradle/gradle.properties | grep "conciergeGerritConfigUserEmail" | sed -e 's|^conciergeGerritConfigUserEmail=||g'`
fi
fi
if [ "$GERRIT_USERNAME" == "" -o "$GERRIT_PASSWORD" == "" -o "$GERRIT_CONFIG_USER_NAME" == "" -o "$GERRIT_CONFIG_USER_EMAIL" == "" ] ; then
echo "Error: you have to set GERRIT_USERNAME, GERRIT_PASSWORD, GERRIT_CONFIG_USER_NAME and GERRIT_CONFIG_USER_EMAIL values, or add"
echo " conciergeGerritUsername=your-username"
echo " conciergeGerritPassword=your-http-password"
echo " conciergeGerritConfigUserName=Your name"
echo " conciergeGerritConfigUserEmail=<your-email>"
echo " to your ~/.gradle/gradle.properties"
echo " Note: GERRIT_PASSWORD is the HTTP password which can bet generated at https://git.eclipse.org/r/#/settings/http-password"
exit 1
fi
git clone https://$GERRIT_USERNAME:$GERRIT_PASSWORD@git.eclipse.org/r/a/www.eclipse.org/concierge
cd concierge
git config --local user.name $GERRIT_CONFIG_USER_NAME
git config --local user.email $GERRIT_CONFIG_USER_EMAIL
# remove existing files
rm -rf *.php ./css ./docs ./images ./includes ./repository
# copy new website
cp -r $GENERATED_DIR/* .
git status
exit 0
fi
if [ "$1" == "commit" ] ; then
cd $REPO_DIR/concierge
now=`date '+%Y-%m-%d %H:%M:%S'`
git add -A
# we have to set the author for CI build as it is running with a non-committer user
git commit -m "Updated website from GitHub at $now" --author "$GERRIT_CONFIG_USER_NAME $GERRIT_CONFIG_USER_EMAIL"
git log -2
exit 0
fi
if [ "$1" == "push" ] ; then
cd $REPO_DIR/concierge
git push
exit 0
fi