[Skip-CI] WIP Build only when new data available

This commit is contained in:
erik 2022-12-02 09:37:03 +01:00
parent fb5fd905cc
commit a844a9e947
2 changed files with 45 additions and 4 deletions

View file

@ -10,8 +10,38 @@ set -eo pipefail
source /usr/local/bin/functions.sh source /usr/local/bin/functions.sh
echo "Downloading website" filename="website.zip"
get-and-unzip-website-data hashfilename="hashfile"
# download website data
# check if hashfile exists
# if yes
# hash the current file
# compare current hash to hashfile
# same?
# do nothing
# not same?
# overwrite hashfile with new hash
# start the website build
# if not
# hash the current file
# write the hashfile
# start the build
echo "Downloading website data"
get-website-data filename
echo "Check for new content"
if [[ -f $hashfile ]]
then
currentHash=$( sha256sum $SOURCEDIR/$filename | cut -d " " -f 1 > ~/$2 ) #ToDo: output of sh256sum without path to file?
else
write-hashfile $filename $hashfilename
fi
echo "Executing Custom Scripts, if applicable" echo "Executing Custom Scripts, if applicable"
execute-scripts-when-existing execute-scripts-when-existing
echo "Building website" echo "Building website"

View file

@ -1,8 +1,19 @@
#!/bin/bash #!/bin/bash
function get-and-unzip-website-data() { function get-website-data() {
filename="website.zip"
curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$filename $GITREPOURL curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$filename $GITREPOURL
}
function write-hashfile() {
(cd $SOURCEDIR; sha256sum $1 | cut -d " " -f 1 > ~/$2;)
}
function compare-website-data() {
oldHash="$( cat ~/hashfile )"
}
function unzip-website-data() {
unzip $SOURCEDIR/$filename -d $BUILDDIR unzip $SOURCEDIR/$filename -d $BUILDDIR
} }