Add short tags for released images (#446)

* Add short tags for images

* Edit workflow tags
This commit is contained in:
Danil Titarenko 2022-06-10 15:43:50 +03:00 committed by GitHub
parent a6562f4017
commit 86cbb01bbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 7 deletions

View file

@ -16,8 +16,8 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
edition: ["", "-ee", "-de"]
images: ["documentserver-stable"] images: ["documentserver-stable"]
edition: ["", "-ee", "-de"]
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -41,18 +41,23 @@ jobs:
- name: Build documentserver-stable - name: Build documentserver-stable
run: | run: |
DOCKER_TAG=$(echo ${{ steps.tag_name.outputs.SOURCE_TAG }} | sed 's/^.//; s/-stable//') TAG=$(echo ${{ steps.tag_name.outputs.SOURCE_TAG }} | sed 's/^.//; s/-stable//')
IMAGE_STATUS=$(docker manifest inspect ${{ env.COMPANY_NAME }}/4testing-${{ env.PRODUCT_NAME }}${{ matrix.edition }}:$DOCKER_TAG > /dev/null ; echo $?) SHORTER_TAG=$(echo ${TAG} | grep -o -P '^[\d]+\.[\d]+\.[\d]+')
SHORTEST_TAG=$(echo ${TAG} | grep -o -P '^[\d]+\.[\d]+')
IMAGE_STATUS=$(docker manifest inspect ${{ env.COMPANY_NAME }}/4testing-${{ env.PRODUCT_NAME }}${{ matrix.edition }}:$TAG > /dev/null ; echo $?)
if [[ "$IMAGE_STATUS" = "0" ]]; then if [[ "$IMAGE_STATUS" = "0" ]]; then
echo "Image present on docker.hub >> start build stable version" echo "Image present on docker.hub >> start build stable version"
echo "FROM ${{ env.COMPANY_NAME }}/4testing-${{ env.PRODUCT_NAME }}${{ matrix.edition }}:$DOCKER_TAG as ${{ env.PRODUCT_NAME }}-stable" >> Dockerfile.stable echo "FROM ${{ env.COMPANY_NAME }}/4testing-${{ env.PRODUCT_NAME }}${{ matrix.edition }}:$TAG as ${{ env.PRODUCT_NAME }}-stable" >> Dockerfile.stable
PRODUCT_EDITION=${{ matrix.edition }} PRODUCT_NAME=${{ env.PRODUCT_NAME }} \ PRODUCT_EDITION=${{ matrix.edition }} PRODUCT_NAME=${{ env.PRODUCT_NAME }} \
COMPANY_NAME=${{ env.COMPANY_NAME}} DOCKERFILE=Dockerfile.stable TAG=$DOCKER_TAG \ COMPANY_NAME=${{ env.COMPANY_NAME}} DOCKERFILE=Dockerfile.stable \
TAG=$TAG \
SHORTER_TAG=$SHORTER_TAG \
SHORTEST_TAG=$SHORTEST_TAG \
docker buildx bake \ docker buildx bake \
-f docker-bake.hcl ${{ matrix.images }} \ -f docker-bake.hcl ${{ matrix.images }} \
--push ; --push ;
else else
echo "FAILED: Image with tag $DOCKER_TAG do not presented on docker.hub >> build will not started >> exit with 0" echo "FAILED: Image with tag $TAG do not presented on docker.hub >> build will not started >> exit with 0"
exit 0 exit 0
fi fi
shell: bash shell: bash

View file

@ -2,6 +2,14 @@ variable "TAG" {
default = "" default = ""
} }
variable "SHORTER_TAG" {
default = ""
}
variable "SHORTEST_TAG" {
default = ""
}
variable "COMPANY_NAME" { variable "COMPANY_NAME" {
default = "" default = ""
} }
@ -37,7 +45,10 @@ target "documentserver" {
target "documentserver-stable" { target "documentserver-stable" {
target = "documentserver-stable" target = "documentserver-stable"
dockerfile= "${DOCKERFILE}" dockerfile= "${DOCKERFILE}"
tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${TAG}", "docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:latest"] tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${TAG}",
"docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${SHORTER_TAG}",
"docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${SHORTEST_TAG}",
"docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:latest"]
platforms = ["linux/amd64", "linux/arm64"] platforms = ["linux/amd64", "linux/arm64"]
args = { args = {
"PRODUCT_EDITION": "${PRODUCT_EDITION}" "PRODUCT_EDITION": "${PRODUCT_EDITION}"