-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-receive
executable file
·57 lines (49 loc) · 1.22 KB
/
post-receive
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
#!/bin/bash
set -e
# Read the first branch being pushed.
# Ploy.sh Currently only supports building one branch at a time
# (Multiple parallel deployment branches would probably be a huge footgun to support)
read oldrev newrev ref
# Extract the branch name
branch=$(echo $ref | cut -d/ -f3)
echo "Checking out branch $branch"
# Checkout the code
mkdir -p worktree
GIT_WORK_TREE=$(pwd)/worktree git checkout -f $branch
cd $(pwd)/worktree
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
RESET='\033[0m' # No Color
# Run the CI/CD steps
if [ -f ploy/build ]; then
echo "Building..."
chmod +x ploy/build
if ./ploy/build ; then
echo -e "${GREEN}Build complete.${RESET}"
else
echo -e "${RED}Build failed.${RESET}"
exit 1
fi
fi
if [ -f ploy/test ]; then
echo "Testing..."
chmod +x ploy/test
if ./ploy/test ; then
echo -e "${GREEN}Test complete.${RESET}"
else
echo -e "${RED}Test failed.${RESET}"
exit 1
fi
fi
if [ -f ploy/deploy ]; then
echo "Deploying..."
chmod +x ploy/deploy
if ./ploy/deploy ; then
echo -e "${GREEN}Deploy complete.${RESET}"
else
echo -e "${RED}Deploy failed.${RESET}"
exit 1
fi
fi
echo "Done."