Determin the proper image for caching for the build

This commit is contained in:
Philipp Grathwohl 2021-12-04 12:23:56 +01:00
parent 4727162002
commit 4faea7ed20

View file

@ -54,11 +54,17 @@ jobs:
PUBLISH_IMAGE=false
TAGS="${{ env.image-name }}:dev"
# Define the image that will be used as a cached image
# to speed up the build process
BUILD_CACHE_IMAGE_NAME=${TAGS}
if [[ $GITHUB_REF_NAME == master ]] || [[ $GITHUB_REF_NAME == main ]]; then
# when building master/main use :latest tag and the version number
# from the cbpi/__init__.py file
VERSION=$(grep -o -E "(([0-9]{1,2}[.]?){3}[0-9]+)" cbpi/__init__.py)
TAGS="${{ env.image-name }}:latest,${{ env.image-name }}:v${VERSION}"
LATEST_IMAGE=${{ env.image-name }}:latest
BUILD_CACHE_IMAGE_NAME=${LATEST_IMAGE}
TAGS="${LATEST_IMAGE},${{ env.image-name }}:v${VERSION}"
PUBLISH_IMAGE=true
elif [[ $GITHUB_REF_NAME == development ]]; then
PUBLISH_IMAGE=true
@ -67,6 +73,7 @@ jobs:
# Set output parameters.
echo ::set-output name=tags::${TAGS}
echo ::set-output name=publish_image::${PUBLISH_IMAGE}
echo ::set-output name=build_cache_image_name::${BUILD_CACHE_IMAGE_NAME}
- name: Set up QEMU
uses: docker/setup-qemu-action@master