From 2906ee45d815f65eda2965ac4d42a7c1c3a24428 Mon Sep 17 00:00:00 2001 From: Julian Schacher Date: Sat, 10 Aug 2024 19:16:52 +0200 Subject: [PATCH] organize the image publishing/tagging process better Every image gets pushed with a unique version-branch tag by default and then the version and latest tags get only tagged from the main branch and the main branch and the desired version respectively. --- .woodpecker/keycloak.yaml | 23 ++++++++++++++++++----- .woodpecker/nextcloud.yaml | 18 ++++++++++++++---- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.woodpecker/keycloak.yaml b/.woodpecker/keycloak.yaml index f98ad87..06eed66 100644 --- a/.woodpecker/keycloak.yaml +++ b/.woodpecker/keycloak.yaml @@ -28,6 +28,7 @@ steps: image: alpine commands: - mkdir /woodpecker/images + - name: build-image image: gcr.io/kaniko-project/executor entrypoint: @@ -38,6 +39,7 @@ steps: - --destination=${IMAGE_NAME}:${KEYCLOAK_VERSION} - --no-push - --tar-path=/woodpecker/images/keycloak.tar + - name: publish-image image: alpine secrets: @@ -45,16 +47,27 @@ steps: commands: - apk -u add crane - crane auth login git.hamburg.ccc.de -u woodpecker -p $GIT_API_TOKEN - - crane push /woodpecker/images/keycloak.tar $IMAGE_NAME:$KEYCLOAK_VERSION - - name: tag-branch-and-latest + - crane push /woodpecker/images/keycloak.tar $IMAGE_NAME:$KEYCLOAK_VERSION-$CI_COMMIT_BRANCH + + - name: tag-version image: alpine when: - branch: main - - evaluate: 'KEYCLOAK_VERSION == "25.0"' secrets: - GIT_API_TOKEN commands: - apk -u add crane - crane auth login git.hamburg.ccc.de -u woodpecker -p $GIT_API_TOKEN - - crane tag $IMAGE_NAME:$KEYCLOAK_VERSION $CI_COMMIT_BRANCH - - crane tag $IMAGE_NAME:$KEYCLOAK_VERSION latest + - crane tag $IMAGE_NAME:$KEYCLOAK_VERSION-$CI_COMMIT_BRANCH $KEYCLOAK_VERSION + + - name: tag-latest + image: alpine + when: + - branch: main + evaluate: 'KEYCLOAK_VERSION == "25.0"' + secrets: + - GIT_API_TOKEN + commands: + - apk -u add crane + - crane auth login git.hamburg.ccc.de -u woodpecker -p $GIT_API_TOKEN + - crane tag $IMAGE_NAME:$KEYCLOAK_VERSION-$CI_COMMIT_BRANCH latest diff --git a/.woodpecker/nextcloud.yaml b/.woodpecker/nextcloud.yaml index 36b4a19..feea22e 100644 --- a/.woodpecker/nextcloud.yaml +++ b/.woodpecker/nextcloud.yaml @@ -48,9 +48,20 @@ steps: commands: - apk -u add crane - crane auth login git.hamburg.ccc.de -u woodpecker -p $GIT_API_TOKEN - - crane push /woodpecker/images/nextcloud.tar $IMAGE_NAME:$NEXTCLOUD_VERSION + - crane push /woodpecker/images/nextcloud.tar $IMAGE_NAME:$NEXTCLOUD_VERSION-$CI_COMMIT_BRANCH - - name: tag-branch-and-latest + - name: tag-version + image: docker.io/library/alpine + when: + - branch: main + secrets: + - GIT_API_TOKEN + commands: + - apk -u add crane + - crane auth login git.hamburg.ccc.de -u woodpecker -p $GIT_API_TOKEN + - crane tag $IMAGE_NAME:$NEXTCLOUD_VERSION-$CI_COMMIT_BRANCH $NEXTCLOUD_VERSION + + - name: tag-latest image: docker.io/library/alpine when: - branch: main @@ -60,5 +71,4 @@ steps: commands: - apk -u add crane - crane auth login git.hamburg.ccc.de -u woodpecker -p $GIT_API_TOKEN - - crane tag $IMAGE_NAME:$NEXTCLOUD_VERSION $CI_COMMIT_BRANCH - - crane tag $IMAGE_NAME:$NEXTCLOUD_VERSION latest + - crane tag $IMAGE_NAME:$NEXTCLOUD_VERSION-$CI_COMMIT_BRANCH latest