[ci] Add branch tag on sonic-slave-bullseye image. (#13151)

Why I did it
tag sonic-slave-* image with branch.
Only keep sonic-slave-* latest tag when it is master branch and amd64 arch.

How I did it
How to verify it
This commit is contained in:
Liu Shilong 2022-12-26 10:35:15 +08:00 committed by GitHub
parent 948ce3fe09
commit 449ae1332f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -56,6 +56,7 @@ jobs:
set -ex
image_tag=$(BLDENV=${{ parameters.dist }} make -f Makefile.work showtag PLATFORM=generic PLATFORM_ARCH=${{ parameters.arch }} | grep sonic-slave | tail -n 1)
image_latest=$(echo $(echo $image_tag | awk -F: '{print$1}'):latest)
image_branch=$(echo $(echo $image_tag | awk -F: '{print$1}'):$(Build.SourceBranchName))
docker rmi $image_tag || true
if [[ "$(Build.Reason)" =~ [a-zA-Z]*CI ]] && docker pull ${{ parameters.registry_url }}/${image_tag};then
@ -69,7 +70,9 @@ jobs:
docker tag ${image_tag} ${REGISTRY_SERVER}/${image_tag}
docker push ${REGISTRY_SERVER}/${image_tag}
if [[ "${{ parameters.arch }}" == "amd64" ]];then
docker tag ${image_tag} ${REGISTRY_SERVER}/${image_branch}
docker push ${REGISTRY_SERVER}/${image_branch}
if [[ "${{ parameters.arch }}" == "amd64" ]] && [[ "$(Build.SourceBranchName)" == "master" ]];then
docker tag ${image_tag} ${REGISTRY_SERVER}/${image_latest}
docker push ${REGISTRY_SERVER}/${image_latest}
fi