forked from kodeklubben/oppgaver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·36 lines (33 loc) · 845 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
32
33
34
35
36
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BUILDER="$DIR/codeclub_lesson_builder"
# add reference to repo in commit message
REPLACE="Merge pull request "
REPLACE_WITH="kodeklubben/oppgaver"
echo "cleaning dist"
# Set CWD to the location of this file
cd $DIR/dist && \
if [ -e README.md ]
then
find * ! -name README.md -delete
else
rm -r *
fi
echo "pulling changes"
# do not pull changes while in dir
cd $DIR/.. && \
git -C $DIR pull && \
git -C $BUILDER fetch origin master && \
git -C $BUILDER merge --no-edit FETCH_HEAD && \
MESSAGE="$(git -C $DIR log -1 --pretty=%B)" && \
COMMIT_MSG="${MESSAGE/$REPLACE/$REPLACE_WITH}" && \
cd $BUILDER && \
npm install
echo "build and push"
cd $DIR && \
./gulp dist && \
cp -r build/* dist && \
cd dist && \
git add --all . && \
git commit -m "$COMMIT_MSG" && \
git push