Refactoring code

This commit is contained in:
danilapog 2022-07-20 13:01:59 +03:00
parent 6474a749d3
commit dfeb905a64

View file

@ -52,49 +52,55 @@ jobs:
### ➡ In this loop we will check all avalivable documentserver architectures. After that all accessed arch will be added to build-platforms list. ### ### ➡ In this loop we will check all avalivable documentserver architectures. After that all accessed arch will be added to build-platforms list. ###
for ARCH in ${NODE_PLATFORMS}; do for ARCH in ${NODE_PLATFORMS}; do
if [[ ${{ env.RELEASE_VERSION }} == v7.* ]] || [[ ${{ env.RELEASE_VERSION }} == v8.* ]] || [[ ${{ env.RELEASE_VERSION }} == v9.* ]]; then REPO_URL=${{ secrets.REPO_URL }}
PACKAGE_URL_CHECK=${{ secrets.REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_${ARCH}.deb
PACKAGE_URL_BUILD=${{ secrets.REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_TARGETARCH.deb
fi
if [[ ${{ env.RELEASE_VERSION }} == v99.* ]]; then if [[ ${{ env.RELEASE_VERSION }} == v99.* ]]; then
PACKAGE_URL_CHECK=${{ secrets.UNSTABLE_REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_${ARCH}.deb REPO_URL=${{ secrets.UNSTABLE_REPO_URL }}
PACKAGE_URL_BUILD=${{ secrets.UNSTABLE_REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_TARGETARCH.deb
fi fi
PACKAGE_URL_CHECK=${REPO_URL}${{ matrix.edition }}_"$PACKAGE_VERSION"_${ARCH}.deb
PACKAGE_URL_BUILD=${REPO_URL}${{ matrix.edition }}_"$PACKAGE_VERSION"_TARGETARCH.deb
STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" "${PACKAGE_URL_CHECK}") STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" "${PACKAGE_URL_CHECK}")
if [[ "$STATUS" = "200" ]]; then if [[ "$STATUS" = "200" ]]; then
echo "${ARCH} is avalivable >> set like one of build platforms" echo "${ARCH} is avalivable >> set like one of build platforms"
PLATFORMS+=(linux/${ARCH},) PLATFORMS+=(linux/${ARCH},)
BUILD_PLATFORMS=$( echo ${PLATFORMS[@]} | sed 's/ //g' | sed 's/\(.*\),/\1/' ) BUILD_PLATFORMS=$( echo ${PLATFORMS[@]} | sed 's/ //g' | sed 's/\(.*\),/\1/' )
else else
echo "${ARCH} in not avalivable" echo "${ARCH} in not avalivable"
fi fi
done done
### ➡ At this step if there is no access to any platform and platform list is empty, build will exit with 1. ### ### ➡ At this step if there is no access to any platform and platform list is empty, build will exit with 1. ###
if [[ -z ${BUILD_PLATFORMS} ]]; then if [[ -z ${BUILD_PLATFORMS} ]]; then
echo "Have no access to any platform >> exit with 1" echo "Have no access to any platform >> exit with 1"
exit 1 exit 1
fi fi
echo "DONE: Check passed >> Build for platforms: ${BUILD_PLATFORMS}" echo "DONE: Check passed >> Build for platforms: ${BUILD_PLATFORMS}"
### ➡ Preconfiguration for debugging with --print key ### ### ➡ Preconfiguration for debugging with --print key ###
PRODUCT_EDITION=${{ matrix.edition }} PACKAGE_URL=$PACKAGE_URL_BUILD \ PRODUCT_EDITION=${{ matrix.edition }} \
PRODUCT_NAME=${{ env.PRODUCT_NAME }} DOCKERFILE=Dockerfile \ PACKAGE_URL=$PACKAGE_URL_BUILD \
PREFIX_NAME=4testing- TAG=$DOCKER_TAG PLATFORM=$BUILD_PLATFORMS \ PRODUCT_NAME=${{ env.PRODUCT_NAME }} \
COMPANY_NAME=${{ env.COMPANY_NAME }} \ DOCKERFILE=Dockerfile \
PREFIX_NAME=4testing- \
TAG=$DOCKER_TAG \
PLATFORM=$BUILD_PLATFORMS \
COMPANY_NAME=${{ env.COMPANY_NAME }} \
docker buildx bake \ docker buildx bake \
-f docker-bake.hcl ${{ matrix.images }} \ -f docker-bake.hcl ${{ matrix.images }} \
--print --print
echo "Build is starting ... >>" echo "Build is starting ... >>"
### ➡ Build and push images at this step ### ### ➡ Build and push images at this step ###
PRODUCT_EDITION=${{ matrix.edition }} PACKAGE_URL=$PACKAGE_URL_BUILD \ PRODUCT_EDITION=${{ matrix.edition }} \
PRODUCT_NAME=${{ env.PRODUCT_NAME }} DOCKERFILE=Dockerfile \ PACKAGE_URL=$PACKAGE_URL_BUILD \
PREFIX_NAME=4testing- TAG=$DOCKER_TAG PLATFORM=$BUILD_PLATFORMS \ PRODUCT_NAME=${{ env.PRODUCT_NAME }} \
COMPANY_NAME=${{ env.COMPANY_NAME }} \ DOCKERFILE=Dockerfile \
PREFIX_NAME=4testing- \
TAG=$DOCKER_TAG \
PLATFORM=$BUILD_PLATFORMS \
COMPANY_NAME=${{ env.COMPANY_NAME }} \
docker buildx bake \ docker buildx bake \
-f docker-bake.hcl ${{ matrix.images }} \ -f docker-bake.hcl ${{ matrix.images }} \
--push --push
echo "DONE: Build success >> exit with 0" echo "DONE: Build success >> exit with 0"
exit 0 exit 0
shell: bash shell: bash