-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·73 lines (57 loc) · 1.61 KB
/
entrypoint.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
#!/bin/sh -l
set -e
echo "DOCKER BUILD AND PUSH"
echo "Environment: "
echo "- BUILD_PATH: ${BUILD_PATH}";
echo "- DOCKER_FILE: ${DOCKER_FILE}";
echo "- CONTAINER_TAG: ${CONTAINER_TAG}";
echo "- GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}";
echo "- GITHUB_EVENT_PATH: ${GITHUB_EVENT_PATH}";
echo "- GITHUB_REF: ${GITHUB_REF}";
echo "- GITHUB_WORKSPACE: ${GITHUB_WORKSPACE}";
echo "- GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}";
echo "- GITHUB_ACTOR: ${GITHUB_ACTOR}";
echo "- MAVEN_SETTINGS: ${MAVEN_SETTINGS}";
if [[ -z "$GITHUB_EVENT_NAME" ]]; then
echo "Set the GITHUB_EVENT_NAME env variable."
exit 1
fi
if [[ -z "$GITHUB_EVENT_PATH" ]]; then
echo "Set the GITHUB_EVENT_PATH env variable."
exit 1
fi
if [[ -z "$GITHUB_REF" ]]; then
echo "Set the GITHUB_REF env variable."
exit 1
fi
if [ -z "${DOCKER_FILE}" ]
then
echo "No Dockerfile spectified. Using default file: Dockerfile"
DOCKER_FILE=Dockerfile
fi
if [[ -z "$CONTAINER_TAG" ]]; then
echo "Set the CONTAINER_TAG env variable."
exit 1
fi
ls -al
if [ -n "${BUILD_PATH}" ]
then
cd ${BUILD_PATH}
fi
if [ -n "${MAVEN_SETTINGS}" ]
then
echo "Generating Maven settings.xml file"
echo "$MAVEN_SETTINGS" | base64 -d > settings.xml
# this directory is needed for the universal resolver
mkdir -p ./resolver/java/
echo "$MAVEN_SETTINGS" | base64 -d > ./resolver/java/settings.xml
fi
ls -al
echo "Building container ..."
docker build . -f ${DOCKER_FILE} -t ${CONTAINER_TAG}
if [ -n "${DOCKER_USERNAME}" ]
then
echo "Pushing container to DockerHub ..."
docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
docker push ${CONTAINER_TAG}
fi