-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtravis.sh
46 lines (28 loc) · 885 Bytes
/
travis.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
#!/bin/bash
# Exit on any failure
# Author Montana Mendy
set -e
SECONDS=0
# Get start time
START_TIME=$(date +"%Y%m%dT%H%M%S")
echo "Start Time: ${START_TIME}"
# Check if running in Travis
if [ -z "$TRAVIS_BRANCH" ]; then
echo "Error: this script is meant to run on Travis CI only"
exit 1
fi
# Check if GitHub auth token is set
if [[ -z "$DOCKER_USERNAME" || -z "$DOCKER_PASSWORD" ]]; then
echo "Error: DOCKERHUB environment variables not set"
exit 2
fi
# Login to DockerHub using your env vars you set
echo "${DOCKER_PASSWORD}" | docker login --username $DOCKER_USERNAME --password-stdin
# Run the build
./build.sh
# Get start time
END_TIME=$(date +"%Y%m%dT%H%M")
# Display build time statistics
echo "Build Start Time: ${START_TIME}"
echo "Build End Time: ${END_TIME}"
echo "Build Duration: $(($SECONDS / 60)) minutes $((${SECONDS} % 60)) seconds"