-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.sh
executable file
·76 lines (71 loc) · 1.81 KB
/
render.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
# Render pdf
warnings=0
# Build NPM project
echo Building...
npm run build
if (($? != 0)); then
echo ❌ Build failed
exit 1
fi
echo ✨ Build done.
# Run Built Program. Render PDF to build/index.pdf
echo Rendering...
npm run index
if (($? != 0)); then
echo ❌ Rendering failed
exit 1
fi
echo ✨ Rendering done.
# Copy PDF to renders folder with custom naming scheme.
echo Organizing Files...
# Get git branch for custom naming scheme.
base_name="Royce_Schultz_Resume"
current_branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
branch_hash=$(echo $current_branch | shasum -a 256)
if [ $current_branch = "master" ] || [ $current_branch = "beta" ]; then
filename=$base_name
else
filename=$base_name\_$current_branch
fi
dst=./renders/$filename.pdf
echo Copying to $dst
cp build/index.pdf $dst
if (($? != 0)); then
echo ❌ Copying failed
exit 1
fi
hash_name=renders/hashed/Royce_Schultz_Resume_1$(echo ${current_branch:0:2})$(echo ${branch_hash:0:4}).pdf
echo Copying to $hash_name
cp build/index.pdf $hash_name
if (($? != 0)); then
echo ❌ Copying failed
exit 1
fi
echo ✨ Copying done.
# Convert to png for README.md display
# Requires ImageMacick (https://imagemagick.org/script/download.php)
echo Converting to PNG...
convert \
-density 250 \
$dst \
-background White \
-flatten \
-quality 100 \
./renders/img/$filename.png
if (($? != 0)); then
echo ⚠️ Converting failed
warnings=$((warnings + 1))
else
echo ✨ Converting done.
fi
# If on master or beta branch, copy to root directory for README.md display
if [ $current_branch = "master" ] || [ $current_branch = "beta" ]; then
echo Moving Files
cp $dst ./$filename.pdf
cp ./renders/img/$filename.png ./$filename.png
fi
# Debug Output
if (( $warnings != 0 )); then
echo ⚠️ $warnings warnings
fi
echo ✅ ✨Done✨