2022-06-09 13:27:39 +03:00
### This workflow setup instance then build and push images ###
2022-07-11 13:27:43 +03:00
name : 4testing multiarch-build
2022-06-09 13:27:39 +03:00
on :
push :
tags :
- "v*"
- "!v*-stable"
env :
COMPANY_NAME : "onlyoffice"
PRODUCT_NAME : "documentserver"
jobs :
build :
2022-08-29 11:40:25 +03:00
name : "Build image: DocumentServer${{ matrix.edition }}"
2022-06-09 13:27:39 +03:00
runs-on : ubuntu-latest
strategy :
2022-08-30 14:33:23 +03:00
fail-fast : false
2022-06-09 13:27:39 +03:00
matrix :
images : [ "documentserver" ]
2022-07-11 13:27:43 +03:00
edition : [ "" , "-ee" , "-de" ]
2022-06-09 13:27:39 +03:00
steps :
- name : Checkout code
uses : actions/checkout@v3
- name : Set up QEMU
uses : docker/setup-qemu-action@v2
- name : Set up Docker Buildx
2022-07-21 18:44:06 +03:00
id : buildx
2022-06-09 13:27:39 +03:00
uses : docker/setup-buildx-action@v2
- name : Login to Docker Hub
2022-08-29 11:40:25 +03:00
uses : docker/login-action@v2
2022-06-09 13:27:39 +03:00
with :
username : ${{ secrets.DOCKER_HUB_USERNAME }}
password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name : Get Tag Name
run : |
2022-07-21 18:44:06 +03:00
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
2022-06-09 13:27:39 +03:00
2022-07-11 13:27:43 +03:00
- name : Build 4testing
2022-06-09 13:27:39 +03:00
run : |
2022-07-21 18:44:06 +03:00
### ==>> At this step build variable declaration ###
DOCKER_TAG=$( echo ${{ env.RELEASE_VERSION }} | sed 's/^.//' )
PACKAGE_VERSION=$( echo $DOCKER_TAG | sed -E 's/(.*)\./\1-/' )
NODE_PLATFORMS=$( echo ${{ steps.buildx.outputs.platforms }} | sed 's/linux\///g' | sed 's/,/ /g' )
2022-09-08 15:56:49 +03:00
EXPECTED_PLATFORMS="linux/amd64,linux/arm64"
2022-07-21 18:44:06 +03:00
echo "Start check avalivable build platforms >>"
### ==>> 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
REPO_URL=${{ secrets.REPO_URL }}
if [[ ${{ env.RELEASE_VERSION }} == v99.* ]]; then
REPO_URL=${{ secrets.UNSTABLE_REPO_URL }}
2022-08-24 11:14:59 +03:00
DEVELOP_BUILD=true
2022-07-21 18:44:06 +03:00
fi
PACKAGE_URL_CHECK=${REPO_URL}${{ matrix.edition }}_"$PACKAGE_VERSION"_${ARCH}.deb
STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" "${PACKAGE_URL_CHECK}")
if [[ "$STATUS" = "200" ]]; then
echo "✔ ${ARCH} is avalivable >> set like one of build platforms"
PLATFORMS+=(linux/${ARCH},)
BUILD_PLATFORMS=$( echo ${PLATFORMS[@]} | sed 's/ //g' | sed 's/\(.*\),/\1/' )
else
2022-08-24 11:14:59 +03:00
echo "Х ${ARCH} in not avalivable"
2022-07-21 18:44:06 +03:00
fi
done
PACKAGE_URL_BUILD=$( echo ${PACKAGE_URL_CHECK} | sed -e "s/${PACKAGE_VERSION}_.*.deb/${PACKAGE_VERSION}_TARGETARCH.deb/g" )
### ==>> 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
echo "Have no access to any platform >> exit with 1"
exit 1
2022-06-09 13:27:39 +03:00
fi
2022-07-21 18:44:06 +03:00
echo "DONE: Check passed >> Build for platforms: ${BUILD_PLATFORMS}"
echo "Build is starting ... >>"
2022-09-08 15:56:49 +03:00
### == >> Set exit code for action
if [ ${BUILD_PLATFORMS} == ${EXPECTED_PLATFORMS} ]; then
EXIT_CODE=0
echo "OK: Build platforms is expected"
else
EXIT_CODE=1
echo "WARNING: Build platforms is unexpected action is gonna be marked as Failed"
fi
2022-07-21 18:44:06 +03:00
### ==>> Build and push images at this step ###
PRODUCT_EDITION=${{ matrix.edition }} \
PACKAGE_URL=$PACKAGE_URL_BUILD \
PRODUCT_NAME=${{ env.PRODUCT_NAME }} \
DOCKERFILE=Dockerfile \
PREFIX_NAME=4testing- \
TAG=$DOCKER_TAG \
PLATFORM=$BUILD_PLATFORMS \
COMPANY_NAME=${{ env.COMPANY_NAME }} \
2022-08-24 12:47:47 +03:00
DEVELOP_BUILD=$DEVELOP_BUILD \
2022-07-21 18:44:06 +03:00
docker buildx bake \
-f docker-bake.hcl ${{ matrix.images }} \
--push
2022-09-08 15:56:49 +03:00
echo "DONE: Build success >> exit with ${EXIT_CODE}"
exit ${EXIT_CODE}
2022-06-09 13:27:39 +03:00
shell : bash