-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
31 lines (28 loc) · 920 Bytes
/
deploy.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
#!/bin/bash
gitLastCommit=$(git show --summary --grep="Merge pull request")
if [[ -z "$gitLastCommit" ]]
then
lastCommit=$(git log --format="%H" -n 1)
else
echo "We got a Merge Request!"
#take the last commit and take break every word into an array
arr=($gitLastCommit)
#the 5th element in the array is the commit ID we need. If git log changes, this breaks. :(
lastCommit=${arr[4]}
fi
echo $lastCommit
cd src
filesChanged=$(git diff-tree --no-commit-id --name-only -r $lastCommit)
if [ ${#filesChanged[@]} -eq 0 ]; then
echo "No files to update"
else
for f in $filesChanged
do
#do not upload these files that aren't necessary to the site
if [ "$f" != ".travis.yml" ] && [ "$f" != "deploy.sh" ] && [ "$f" != "test.js" ] && [ "$f" != "package.json" ]
then
echo "Uploading $f"
curl --ftp-create-dirs -T $f -u $FTP_USER:$FTP_PASS ftp://fotocontest.nak-sued.de/web/print-cal/$f
fi
done
fi