Skip to content

Commit 628efbb

Browse files
author
Vladimir Kotal
committed
publish Docker image for non release builds as well
fixes #3570
1 parent 05847ee commit 628efbb

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

dev/docker.sh

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,36 @@ fi
2222
if [[ -n $OPENGROK_TAG ]]; then
2323
VERSION="$OPENGROK_TAG"
2424
VERSION_SHORT=$( echo $VERSION | cut -d. -f1,2 )
25-
else
26-
VERSION="latest"
27-
VERSION_SHORT="latest"
28-
fi
2925

30-
if [[ -z $VERSION ]]; then
31-
echo "empty VERSION"
32-
exit 1
33-
fi
26+
if [[ -z $VERSION ]]; then
27+
echo "empty VERSION"
28+
exit 1
29+
fi
3430

35-
if [[ -z $VERSION_SHORT ]]; then
36-
echo "empty VERSION_SHORT"
37-
exit 1
38-
fi
31+
if [[ -z $VERSION_SHORT ]]; then
32+
echo "empty VERSION_SHORT"
33+
exit 1
34+
fi
35+
36+
echo "Version: $VERSION"
37+
echo "Short version: $VERSION_SHORT"
3938

40-
echo "Version: $VERSION"
41-
echo "Short version: $VERSION_SHORT"
39+
TAGS="$VERSION $VERSION_SHORT latest"
4240

43-
# Build the image.
44-
echo "Building docker image"
45-
docker build \
46-
-t $IMAGE:$VERSION \
47-
-t $IMAGE:$VERSION_SHORT \
48-
-t $IMAGE:latest .
41+
echo "Building docker image for release ($TAGS)"
42+
docker build \
43+
-t $IMAGE:$VERSION \
44+
-t $IMAGE:$VERSION_SHORT \
45+
-t $IMAGE:latest .
46+
else
47+
TAGS="master"
48+
49+
echo "Building docker image for master"
50+
docker build -t $IMAGE:master .
51+
fi
4952

5053
#
51-
# Run the image in container. This is not strictly needed however
54+
# Run the image in a container. This is not strictly needed however
5255
# serves as additional test in automatic builds.
5356
#
5457
echo "Running the image in container"
@@ -67,12 +70,6 @@ if [[ "$OPENGROK_REPO_SLUG" != "oracle/opengrok" ]]; then
6770
exit 0
6871
fi
6972

70-
# Allow Docker push for release builds only.
71-
if [[ -z $OPENGROK_TAG ]]; then
72-
echo "OPENGROK_TAG is empty"
73-
exit 0
74-
fi
75-
7673
if [[ -z $DOCKER_USERNAME ]]; then
7774
echo "DOCKER_USERNAME is empty"
7875
exit 1
@@ -84,12 +81,12 @@ if [[ -z $DOCKER_PASSWORD ]]; then
8481
fi
8582

8683
# Publish the image to Docker hub.
87-
if [ -n "$DOCKER_PASSWORD" -a -n "$DOCKER_USERNAME" -a -n "$VERSION" ]; then
84+
if [ -n "$DOCKER_PASSWORD" -a -n "$DOCKER_USERNAME" -a -n "$TAGS" ]; then
8885
echo "Logging into Docker Hub"
8986
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
9087

9188
# All the tags need to be pushed individually:
92-
for tag in $VERSION $VERSION_SHORT latest; do
89+
for tag in $TAGS; do
9390
echo "Pushing Docker image for tag $tag"
9491
docker push $IMAGE:$tag
9592
done
@@ -120,15 +117,18 @@ push_readme() {
120117
fi
121118
}
122119

123-
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST \
124-
-d '{"username": "'${DOCKER_USERNAME}'", "password": "'${DOCKER_PASSWORD}'"}' \
125-
${API_URL}/users/login/ | jq -r .token)
126-
if [[ -z $TOKEN ]]; then
127-
echo "Cannot get auth token to publish the README file"
128-
exit 1
129-
fi
120+
# Update README and badge only for release builds.
121+
if [[ -n $OPENGROK_TAG ]]; then
122+
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST \
123+
-d '{"username": "'${DOCKER_USERNAME}'", "password": "'${DOCKER_PASSWORD}'"}' \
124+
${API_URL}/users/login/ | jq -r .token)
125+
if [[ -z $TOKEN ]]; then
126+
echo "Cannot get auth token to publish the README file"
127+
exit 1
128+
fi
130129

131-
push_readme "${IMAGE}" "${TOKEN}" "docker/README.md"
130+
push_readme "${IMAGE}" "${TOKEN}" "docker/README.md"
132131

133-
# update Microbadger
134-
curl -s -X POST https://hooks.microbadger.com/images/opengrok/docker/pSastb42Ikfn2dF5llR54sSPqbQ=
132+
# update Microbadger
133+
curl -s -X POST https://hooks.microbadger.com/images/opengrok/docker/pSastb42Ikfn2dF5llR54sSPqbQ=
134+
fi

0 commit comments

Comments
 (0)