1
0
mirror of https://github.com/ONLYOFFICE/Docker-Docs.git synced 2025-04-18 15:04:02 +03:00

Build amd64 only when push in test repo

Co-authored-by: danilapog <danil.titarenko@onlyoffice.com>
Co-committed-by: danilapog <danil.titarenko@onlyoffice.com>
This commit is contained in:
danilapog 2024-12-25 14:24:59 +00:00 committed by Vyacheslav Semin
parent 56b60c7542
commit 10c85ac434
2 changed files with 59 additions and 39 deletions

View File

@ -3,9 +3,7 @@ name: Multi-arch build
run-name: >-
Build Docs: [
${{ inputs.docs-community && 'CE' || '-' }}
${{ inputs.docs-enterprise && 'EE' || '-' }}
${{ inputs.docs-developer && 'DE' || '-' }}
${{ inputs.edition }}
]
${{ inputs.docs-balancer && 'balancer: [✓]' || '' }}
${{ inputs.docs-non-plugins && 'non-plugins: [✓]' || '' }}
@ -15,18 +13,19 @@ run-name: >-
on:
workflow_dispatch:
inputs:
docs-community:
amd64:
type: boolean
description: 'Build Docs-Community'
description: 'Build amd64'
default: true
docs-enterprise:
arm64:
type: boolean
description: 'Build Docs-Enterprise'
default: true
docs-developer:
type: boolean
description: 'Build Docs-Developer'
description: 'Build arm64'
default: true
edition:
description: "Specify edition (ex. 'ce' or 'ce,ee,de')"
type: string
required: true
default: 'de'
docs-non-plugins:
type: boolean
description: 'Build Docs-non-plugins'
@ -45,7 +44,7 @@ on:
required: true
test-repo:
type: boolean
description: 'Push to test repo'
description: 'Push to test-repo'
default: true
test-version:
type: string
@ -64,6 +63,7 @@ jobs:
sourceTag: ${{ steps.prepare.outputs.sourceTag }}
dsHash: ${{ steps.prepare.outputs.dsHash }}
matrix: ${{ steps.prepare.outputs.matrix }}
platform: ${{ steps.prepare.outputs.platform }}
steps:
- name: prepare-build
id: prepare
@ -80,38 +80,52 @@ jobs:
fi
fi
### Make build platforms ###
[ ${{ github.event.inputs.amd64 }} = true ] && PLATFORMS+=("amd64")
[ ${{ github.event.inputs.arm64 }} = true ] && PLATFORMS+=("arm64")
PLATFORM=$(echo ${PLATFORMS[*]/#/linux/} | tr ' ' ',')
### Make build matrix ###
matrix='{"include": []}'
if ${{ github.event.inputs.docs-community }}; then
matrix=$(echo $matrix | jq '.include += [
editions=($(printf "%s\n" ${{ github.event.inputs.edition }} | tr ',' ' '))
for e in ${editions[@]}; do
case ${e} in
ce)
echo "Enable community build..."
matrix=$(echo $matrix | jq '.include += [
{
"name": "Build Docs Community",
"dockerfile": "Dockerfile",
"edition": "",
"name": "Build Docs Community",
"dockerfile": "Dockerfile",
"edition": "",
"images": "proxy docservice converter"
}
]')
fi
if ${{ github.event.inputs.docs-enterprise }}; then
matrix=$(echo $matrix | jq '.include += [
]')
;;
ee)
echo "Enable enterprise build..."
matrix=$(echo $matrix | jq '.include += [
{
"name": "Build Docs Enterprise",
"dockerfile": "Dockerfile",
"edition": "-ee",
"name": "Build Docs Enterprise",
"dockerfile": "Dockerfile",
"edition": "-ee",
"images": "proxy docservice converter"
}
]')
fi
if ${{ github.event.inputs.docs-developer }}; then
matrix=$(echo $matrix | jq '.include += [
]')
;;
de)
echo "Enable developer build..."
matrix=$(echo $matrix | jq '.include += [
{
"name": "Build Docs Developer",
"dockerfile": "Dockerfile",
"edition": "-de",
"name": "Build Docs Developer",
"dockerfile": "Dockerfile",
"edition": "-de",
"images": "proxy docservice converter"
}
]')
fi
]')
;;
esac
done
if ${{ github.event.inputs.docs-non-plugins }}; then
matrix=$(echo $matrix | jq '.include += [
{
@ -148,6 +162,7 @@ jobs:
echo "sourceTag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
echo "dsHash=$(echo -n "$(date +'%Y.%m.%d-%H%M')" | md5sum | awk '{print $1}')" >> "$GITHUB_OUTPUT"
echo "matrix=$(echo $matrix | jq -c)" >> "$GITHUB_OUTPUT"
echo "platform=${PLATFORM[@]}" >> "$GITHUB_OUTPUT"
build:
name: "${{ matrix.name }} ${{ github.event.inputs.tag }}"
@ -178,6 +193,7 @@ jobs:
REGISTRY: ${{ inputs.test-repo && secrets.DOCKER_TEST_REGISTRY || 'docker.io' }}
DS_VERSION_HASH: ${{ needs.prepare-build.outputs.dsHash }}
SOURCE_TAG: ${{ needs.prepare-build.outputs.sourceTag }}
PLATFORM: ${{ needs.prepare-build.outputs.platform }}
NOPLUG_POSTFIX: ${{ matrix.postfix }}
DOCKERFILE: ${{ matrix.dockerfile }}
TEST_VERSION: ${{ github.event.inputs.test-version }}

View File

@ -39,6 +39,10 @@ variable "RELEASE_VERSION" {
default = ""
}
variable "PLATFORM" {
default = ""
}
group "apps" {
targets = ["proxy", "converter", "docservice", "example"]
}
@ -48,7 +52,7 @@ target "example" {
dockerfile = "${DOCKERFILE}"
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-example${PRODUCT_EDITION}:${TAG}"] : [
"${REGISTRY}/${PREFIX_NAME}-example${PRODUCT_EDITION}:${TAG}" ]
platforms = ["linux/amd64", "linux/arm64"]
platforms = ["${PLATFORM}"]
args = {
"PRODUCT_EDITION": "${PRODUCT_EDITION}"
}
@ -59,7 +63,7 @@ target "proxy" {
dockerfile = "${DOCKERFILE}"
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-proxy${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}"] : [
"${REGISTRY}/${PREFIX_NAME}-proxy${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}" ]
platforms = ["linux/amd64", "linux/arm64"]
platforms = ["${PLATFORM}"]
args = {
"PRODUCT_EDITION": "${PRODUCT_EDITION}"
"DS_VERSION_HASH": "${DS_VERSION_HASH}"
@ -73,7 +77,7 @@ target "converter" {
dockerfile = "${DOCKERFILE}"
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-converter${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}"] : [
"${REGISTRY}/${PREFIX_NAME}-converter${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}" ]
platforms = ["linux/amd64", "linux/arm64"]
platforms = ["${PLATFORM}"]
args = {
"PRODUCT_EDITION": "${PRODUCT_EDITION}"
"DS_VERSION_HASH": "${DS_VERSION_HASH}"
@ -87,7 +91,7 @@ target "docservice" {
dockerfile = "${DOCKERFILE}"
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-docservice${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}"] : [
"${REGISTRY}/${PREFIX_NAME}-docservice${PRODUCT_EDITION}:${TAG}${NOPLUG_POSTFIX}" ]
platforms = ["linux/amd64", "linux/arm64"]
platforms = ["${PLATFORM}"]
args = {
"PRODUCT_EDITION": "${PRODUCT_EDITION}"
"DS_VERSION_HASH": "${DS_VERSION_HASH}"
@ -101,7 +105,7 @@ target "utils" {
dockerfile = "${DOCKERFILE}"
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-utils:${TAG}"] : [
"${REGISTRY}/${PREFIX_NAME}-utils:${TAG}" ]
platforms = ["linux/amd64", "linux/arm64"]
platforms = ["${PLATFORM}"]
args = {
"DS_VERSION_HASH": "${DS_VERSION_HASH}"
"PRODUCT_BASEURL": "${PRODUCT_BASEURL}"
@ -114,6 +118,6 @@ target "balancer" {
dockerfile = "${DOCKERFILE}"
tags = equal("docker.io",REGISTRY) ? ["${REGISTRY}/${COMPANY_NAME}/${PREFIX_NAME}-balancer:${TAG}"] : [
"${REGISTRY}/${PREFIX_NAME}-balancer:${TAG}" ]
platforms = ["linux/amd64", "linux/arm64"]
platforms = ["${PLATFORM}"]
}