-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__build.sh
executable file
·98 lines (74 loc) · 2.9 KB
/
__build.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
#!/bin/bash
# set -e
CURR_COMMIT=$(git log --oneline -n 1)
PROJECT_PATH=$(pwd)
PROJECT_DIR=$7
AWS_ASSET_FILES=(${PROJECT_PATH}/src/aws-assets/*)
AWS_DATA_FILES=(${PROJECT_PATH}/src/aws-data/*)
mkdir -p $1
cd $1
QZTHINGS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
printf '%s\n'
printf '\e[0;35m%s\e[0m\n' "Executing pull of qz-things from origin:${QZTHINGS_BRANCH}"
printf '%s\n' -------------------------
echo `git pull origin ${QZTHINGS_BRANCH}`
cd -
if [[ "$3" = true ]]; then
printf '%s\n'
printf '\e[0;35m%s\e[0m\n' "Copying built files to qz-things repo"
printf '%s\n' -------------------------
cp -rv ./build/* $1
fi
cd $1
if [[ "$4" = true ]]; then
printf '%s\n'
printf '\e[0;35m%s\e[0m\n' "Committing ${CURR_COMMIT} to origin:${QZTHINGS_BRANCH}"
printf '%s\n' -------------------------
git add .
git commit -m "built: ${2} | ${CURR_COMMIT}"
fi
if [[ "$5" = true ]]; then
printf '%s\n'
printf '\e[0;35m%s\e[0m\n' "Pushing to origin:${QZTHINGS_BRANCH}"
printf '%s\n' -------------------------
git push origin ${QZTHINGS_BRANCH}
fi
cd -
if [ "$6" = true ] && [ ${#AWS_ASSET_FILES[@]} -gt 0 ] && [ ${#AWS_DATA_FILES[@]} -gt 0 ]; then
printf '%s\n'
printf '\e[0;35m%s\e[0m\n' "Transfering new and modified files to S3"
printf '%s\n' -------------------------
aws s3 sync ${PROJECT_PATH}/src/aws-assets s3://things-assets.qz.com${PROJECT_DIR}/assets --exclude '_placeholder'
aws s3 sync ${PROJECT_PATH}/src/aws-data s3://things-assets.qz.com${PROJECT_DIR}/data --exclude '_placeholder'
printf '%s\n'
printf '\e[0;35m%s\e[0m\n' "Some of your files are available in the following locations:"
if [ ${#AWS_ASSET_FILES[@]} -gt 0 ]; then
printf '%s\n' https://things-assets.qz.com${PROJECT_DIR}/assets/
fi
if [ ${#AWS_DATA_FILES[@]} -gt 0 ]; then
printf '%s\n' https://things-assets.qz.com${PROJECT_DIR}/data/
fi
fi
if [[ "$5" = true ]]; then
printf '%s\n'
cd ./build
HTML_FILES=$(ls *.html | grep -v "info.html")
printf '\e[1;32m%s\e[0m\n' "================================================"
printf '\e[1;32m%s\e[0m\n' "++++++++ Your project has been deployed ++++++++"
printf '\e[1;32m%s\e[0m\n' "================================================"
printf '%s\n'
printf '\e[0;32m%s\e[0m\n' "These are html files in the project’s directory:"
printf 'https://things.qz.com'${PROJECT_DIR}'/%s\n' $HTML_FILES
printf '%s\n'
printf '\e[0;32m%s\e[0m\n' "Your medium-sized embed short-codes:"
printf '[qz-interactive url="https://things.qz.com'${PROJECT_DIR}'/%s" size="medium"]\n' $HTML_FILES
printf '%s\n'
printf '\e[0;32m%s\e[0m\n' "Your large-sized embed short-codes:"
printf '[qz-interactive url="https://things.qz.com'${PROJECT_DIR}'/%s" size="large"]\n' $HTML_FILES
# printf '%s\n'
# printf '\e[0;32m%s\e[0m\n' "Your extra-large-sized embed short-codes:"
# printf '[qz-interactive url="https://things.qz.com'${PROJECT_DIR}'/%s" size="x-large"]\n' $HTML_FILES
printf '%s\n'
cd -
printf '%s\n'
fi