### 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 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 run: | echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Build 4testing run: | DOCKER_TAG=$(echo ${{ env.RELEASE_VERSION }} | sed 's/^.//' ) PACKAGE_VERSION=$( echo $DOCKER_TAG | sed -E 's/(.*)\./\1-/' ) if [[ ${{ env.RELEASE_VERSION }} == v99.99* ]]; then sed -i "s|http://download.onlyoffice.com/install/documentserver/linux/\${COMPANY_NAME}-\${PRODUCT_NAME}\${PRODUCT_EDITION}|${{ secrets.UNSTABLE_REPO_URL }}${{ matrix.edition }}_$PACKAGE_VERSION|g" Dockerfile PACKAGE_URL=${{ secrets.UNSTABLE_REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_amd64.deb else 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 PACKAGE_URL=${{ secrets.REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_amd64.deb fi 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" AMD64=present else echo "ALARM: Have no access to documentserver${{ matrix.edition }} amd64" AMD64= fi if [[ ${{ env.RELEASE_VERSION }} == v99.99* ]]; then PACKAGE_URL=${{ secrets.UNSTABLE_REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_arm64.deb else PACKAGE_URL=${{ secrets.REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_arm64.deb fi 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" ARM64=present else echo "ALARM: Have no access to documentserver${{ matrix.edition }} arm64" ARM64= fi ##### this setting up build platform #### if [[ "$AMD64" = "present" ]] && [[ "$ARM64" = "present" ]]; then PLATFORM="linux/amd64,linux/arm64" echo "Present arm64/amd64, build miltiarch" fi if [[ "$AMD64" != "present" ]] && [[ "$ARM64" = "present" ]]; then PLATFORM="linux/arm64" echo "Present only arm64, build arm image" fi if [[ "$AMD64" = "present" ]] && [[ "$ARM64" != "present" ]]; then PLATFORM="linux/amd64" echo "Present only amd64, build amd image" fi if [[ "$AMD64" != "present" ]] && [[ "$ARM64" != "present" ]]; then echo "FAILED: Build will not started requested architectures does not present" exit 1 fi PRODUCT_EDITION=${{ matrix.edition }} COMPANY_NAME=${{ env.COMPANY_NAME }} \ PRODUCT_NAME=${{ env.PRODUCT_NAME }} DOCKERFILE=Dockerfile \ PREFIX_NAME=4testing- TAG=$DOCKER_TAG PLATFORM=$PLATFORM \ docker buildx bake \ -f docker-bake.hcl ${{ matrix.images }} \ --print echo "Start build >>" PRODUCT_EDITION=${{ matrix.edition }} COMPANY_NAME=${{ env.COMPANY_NAME }} \ PRODUCT_NAME=${{ env.PRODUCT_NAME }} DOCKERFILE=Dockerfile \ PREFIX_NAME=4testing- TAG=$DOCKER_TAG PLATFORM=$PLATFORM \ docker buildx bake \ -f docker-bake.hcl ${{ matrix.images }} \ --push echo "DONE: Build success >> exit with 0" exit 0 shell: bash