-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-version.sh
More file actions
executable file
·25 lines (21 loc) · 1.08 KB
/
Copy pathget-version.sh
File metadata and controls
executable file
·25 lines (21 loc) · 1.08 KB
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
#!/bin/bash
export IMG=$(docker build -q --pull --no-cache -t 'get-version' .)
export DEBIAN_VERSION=$(docker run --rm -t get-version cat /etc/debian_version | tail -n1 | tr -d '\r')
export APACHE_VERSION=$(docker run --rm -t get-version dpkg --list apache2 | grep '^ii' | tr ' ' '\n' | grep '[0-9]\.[0-9]'| sed 's/[+=~:]/_/g' | tr -d '\r')
export PHPMYADMIN_VERSION=$(docker run --rm -t get-version ls /var/www/html/phpmyadmin/RELEASE-DATE* | tr '-' '\n' | grep '[0-9]\.[0-9]')
[ -z "$DEBIAN_VERSION" ] && exit 1
export IMGTAG=$(echo "$1""d$DEBIAN_VERSION-a$APACHE_VERSION-p$PHPMYADMIN_VERSION")
# FORCE_REBUILD (set by the workflow for push / manual runs) rebuilds even if
# the versioned image already exists, so code/config changes get republished.
# the nightly schedule leaves it unset and keeps deduping on the version tag.
if [ -n "$FORCE_REBUILD" ]; then
echo "$IMGTAG"
exit 0
fi
export IMAGE_EXISTS=$(docker pull "$IMGTAG" 2>/dev/null >/dev/null; echo $?)
# return latest, if container is already available :)
if [ "$IMAGE_EXISTS" -eq 0 ]; then
echo "$1""latest"
else
echo "$IMGTAG"
fi