2213fc70f5
* 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
94 lines
3.4 KiB
YAML
94 lines
3.4 KiB
YAML
### This workflow setup instance then build and push images ###
|
|
name: 4testing multiarch-build
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
- "!v*-stable"
|
|
|
|
env:
|
|
COMPANY_NAME: "onlyoffice"
|
|
PRODUCT_NAME: "documentserver"
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
continue-on-error: ${{ matrix.condition }}
|
|
strategy:
|
|
matrix:
|
|
images: ["documentserver"]
|
|
edition: ["", "-ee", "-de"]
|
|
condition: [true]
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
|
|
- name: Get Tag Name
|
|
run: |
|
|
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
|
|
- name: Build 4testing
|
|
run: |
|
|
### ==>> 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
|