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

Only commit if version actually changed

parent 874fa869
Branches
No related tags found
No related merge requests found
Pipeline #3605 passed
......@@ -5,20 +5,23 @@ stages:
variables:
DOCKER_IMAGE: cverstege/alma9-base
before_script:
- apt-get update && apt-get install -y curl git
Update Upstream 🛠️:
stage: ⏫ Update
before_script:
- apt-get update && apt-get install -y curl git
script:
- ./alma9-base/update.sh
- CURRENT_TAG=$(grep 'FROM cern/alma9-base:' alma9-base/Dockerfile | sed 's/FROM cern\/alma9-base:\([[:alnum:].-]*\).*/\1/')
- git config user.name "CI Pipeline"
- git config user.email "cedric.verstege@kit.edu"
- git add alma9-base/Dockerfile
- git commit -m "⏫ Update upstream to version $CURRENT_TAG"
- git remote set-url --push origin "https://$CI_COMMITTER_USER_AND_TOKEN@gitlab.etp.kit.edu/cverstege/docker-images.git"
- git push origin HEAD:$CI_COMMIT_REF_NAME
- ./alma9-base/update.sh
- |-
if [[ "${LATEST_TAG}" != "${CURRENT_TAG}" ]]; then
git add alma9-base/Dockerfile
git commit -m "[🛠️ CI] ⏫ Update to upstream version $CURRENT_TAG"
git remote set-url --push origin "https://$CI_COMMITTER_USER_AND_TOKEN@gitlab.etp.kit.edu/cverstege/docker-images.git"
git push origin HEAD:$CI_COMMIT_REF_NAME
else
echo "Version didn't change, nothing to do!"
fi
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: always
......
......@@ -8,9 +8,10 @@ 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}"
export LATEST_TAG
export CURRENT_TAG
if [[ "${LATEST_TAG}" == "${CURRENT_TAG}" ]]; then
echo "Already on latest image; nothing to do."
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment