Skip to content
Snippets Groups Projects
Commit c49c29fd authored by Cedric Verstege's avatar Cedric Verstege
Browse files

Add update script

parent 383fadcc
Branches
No related tags found
No related merge requests found
Pipeline #3590 passed with warnings
#!/usr/bin/env bash
set -euo pipefail
THIS_DIR=$(dirname "$0")
function update() {
echo "Fetching the latest tag for cern/alma9-base"
LATEST_TAG=$(curl -s https://registry.hub.docker.com/v2/repositories/cern/alma9-base/tags/ | grep -oP '"name":\s*"\K(\d{8}-\d+)'| sort -V | tail -n 1)
echo "Latest tag is ${LATEST_TAG}"
CURRENT_TAG=$(grep -oP "FROM cern/alma9-base:\K[\w.-]+" "${THIS_DIR}/Dockerfile")
echo "Current tag is ${CURRENT_TAG}"
if [[ "${LATEST_TAG}" == "${CURRENT_TAG}" ]]; then
echo "Already on latest image; nothing to do."
else
echo "Updating Dockerfile to ${LATEST_TAG}"
sed -i "s|FROM cern/alma9-base:${CURRENT_TAG}|FROM cern/alma9-base:${LATEST_TAG}|g" "$THIS_DIR/Dockerfile";
fi
}
update
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment