organize the image publishing/tagging process better
All checks were successful
ci/woodpecker/push/keycloak Pipeline was successful
ci/woodpecker/push/nextcloud/2 Pipeline was successful
ci/woodpecker/push/nextcloud/1 Pipeline was successful

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.
This commit is contained in:
June 2024-08-10 19:16:52 +02:00
parent 6783e974b9
commit 2906ee45d8
Signed by: june
SSH key fingerprint: SHA256:o9EAq4Y9N9K0pBQeBTqhSDrND5E7oB+60ZNx0U1yPe0
2 changed files with 32 additions and 9 deletions

View file

@ -28,6 +28,7 @@ steps:
image: alpine image: alpine
commands: commands:
- mkdir /woodpecker/images - mkdir /woodpecker/images
- name: build-image - name: build-image
image: gcr.io/kaniko-project/executor image: gcr.io/kaniko-project/executor
entrypoint: entrypoint:
@ -38,6 +39,7 @@ steps:
- --destination=${IMAGE_NAME}:${KEYCLOAK_VERSION} - --destination=${IMAGE_NAME}:${KEYCLOAK_VERSION}
- --no-push - --no-push
- --tar-path=/woodpecker/images/keycloak.tar - --tar-path=/woodpecker/images/keycloak.tar
- name: publish-image - name: publish-image
image: alpine image: alpine
secrets: secrets:
@ -45,16 +47,27 @@ steps:
commands: commands:
- apk -u add crane - apk -u add crane
- crane auth login git.hamburg.ccc.de -u woodpecker -p $GIT_API_TOKEN - crane auth login git.hamburg.ccc.de -u woodpecker -p $GIT_API_TOKEN
- crane push /woodpecker/images/keycloak.tar $IMAGE_NAME:$KEYCLOAK_VERSION - crane push /woodpecker/images/keycloak.tar $IMAGE_NAME:$KEYCLOAK_VERSION-$CI_COMMIT_BRANCH
- name: tag-branch-and-latest
- name: tag-version
image: alpine image: alpine
when: when:
- branch: main - branch: main
- evaluate: 'KEYCLOAK_VERSION == "25.0"'
secrets: secrets:
- GIT_API_TOKEN - GIT_API_TOKEN
commands: commands:
- apk -u add crane - apk -u add crane
- crane auth login git.hamburg.ccc.de -u woodpecker -p $GIT_API_TOKEN - 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-$CI_COMMIT_BRANCH $KEYCLOAK_VERSION
- crane tag $IMAGE_NAME:$KEYCLOAK_VERSION latest
- 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

View file

@ -48,9 +48,20 @@ steps:
commands: commands:
- apk -u add crane - apk -u add crane
- crane auth login git.hamburg.ccc.de -u woodpecker -p $GIT_API_TOKEN - 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 image: docker.io/library/alpine
when: when:
- branch: main - branch: main
@ -60,5 +71,4 @@ steps:
commands: commands:
- apk -u add crane - apk -u add crane
- crane auth login git.hamburg.ccc.de -u woodpecker -p $GIT_API_TOKEN - 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-$CI_COMMIT_BRANCH latest
- crane tag $IMAGE_NAME:$NEXTCLOUD_VERSION latest