Add another tags processing (#464)

* Add support for processing other tags

* Print build-info before build start

* Cosmetic changes

* Add architecture and URL processing

* Refactoring action code

* Refactoring code

* Refactoring code

* Cosmetic changes

* Remove some check package version

* Refactoring code

* Redefining url variable for dockerfile

* Cosmetic changes

* Changes platform conditions check

* Set to use default TARGETARCH in build
This commit is contained in:
Danil Titarenko 2022-07-21 18:44:06 +03:00 committed by GitHub
parent 06a05223b5
commit 2213fc70f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 31 deletions

@ -29,6 +29,7 @@ jobs:
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
@ -38,38 +39,55 @@ jobs:
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Get Tag Name
id: tag_name
run: |
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build 4testing
run: |
DOCKER_TAG=$(echo ${{ steps.tag_name.outputs.SOURCE_TAG }} | sed 's/^.//' )
PACKAGE_VERSION=$(echo $DOCKER_TAG | sed 's/\./-/3')
PACKAGE_URL=${{ secrets.REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_amd64.deb
STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" "$PACKAGE_URL")
if [[ "$STATUS" = "200" ]]; then
echo "Have access to documentserver${{ matrix.edition }} amd64 arch >> check arm64 access"
else
echo "FAILED: Have no access to documentserver${{ matrix.edition }} amd64 arch"
exit 1
fi
PACKAGE_URL=${{ secrets.REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_arm64.deb
STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" "$PACKAGE_URL")
if [[ "$STATUS" = "200" ]]; then
echo "Have access to documentserver${{ matrix.edition }} arm64 arch"
echo "All architecture are available >> build is starting."
sed -i "s|http://download.onlyoffice.com/install/documentserver/linux/\${COMPANY_NAME}-\${PRODUCT_NAME}\${PRODUCT_EDITION}|${{ secrets.REPO_URL }}${{ matrix.edition }}_$PACKAGE_VERSION|g" Dockerfile
PRODUCT_EDITION=${{ matrix.edition }} COMPANY_NAME=${{ env.COMPANY_NAME }} \
PRODUCT_NAME=${{ env.PRODUCT_NAME }} DOCKERFILE=Dockerfile \
PREFIX_NAME=4testing- TAG=$DOCKER_TAG \
docker buildx bake \
-f docker-bake.hcl ${{ matrix.images }} \
--push
echo "DONE: Build success >> exit with 0"
exit 0
else
echo "FAILED: Have no access to some required architecture documentserver${{ matrix.edition }} >> Exit with 0."
exit 1
### ==>> 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' )
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 }}
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
echo "${ARCH} in not avalivable"
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
fi
echo "DONE: Check passed >> Build for platforms: ${BUILD_PLATFORMS}"
echo "Build is starting ... >>"
### ==>> 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 }} \
docker buildx bake \
-f docker-bake.hcl ${{ matrix.images }} \
--push
echo "DONE: Build success >> exit with 0"
exit 0
shell: bash

@ -81,7 +81,8 @@ ENV COMPANY_NAME=$COMPANY_NAME \
PRODUCT_NAME=$PRODUCT_NAME \
PRODUCT_EDITION=$PRODUCT_EDITION
RUN wget -q -P /tmp "$PACKAGE_URL" && \
RUN PACKAGE_URL=$( echo ${PACKAGE_URL} | sed "s/TARGETARCH/"${TARGETARCH}"/g") && \
wget -q -P /tmp "$PACKAGE_URL" && \
apt-get -y update && \
service postgresql start && \
apt-get -yq install /tmp/$(basename "$PACKAGE_URL") && \

@ -30,15 +30,25 @@ variable "DOCKERFILE" {
default = ""
}
variable "PLATFORM" {
default = ""
}
variable "PACKAGE_URL" {
default = ""
}
target "documentserver" {
target = "documentserver"
dockerfile= "${DOCKERFILE}"
tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${TAG}"]
platforms = ["linux/amd64", "linux/arm64"]
platforms = ["${PLATFORM}"]
args = {
"PRODUCT_EDITION": "${PRODUCT_EDITION}"
"PRODUCT_NAME": "${PRODUCT_NAME}"
"COMPANY_NAME": "${COMPANY_NAME}"
"PACKAGE_URL": "{PACKAGE_URL}"
"PLATFORM": "${PLATFORM}"
}
}