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:
parent
06a05223b5
commit
2213fc70f5
3 changed files with 60 additions and 31 deletions
76
.github/workflows/4testing-build.yml
vendored
76
.github/workflows/4testing-build.yml
vendored
|
@ -29,6 +29,7 @@ jobs:
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
|
@ -38,38 +39,55 @@ jobs:
|
||||||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
||||||
|
|
||||||
- name: Get Tag Name
|
- name: Get Tag Name
|
||||||
id: tag_name
|
|
||||||
run: |
|
run: |
|
||||||
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
|
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Build 4testing
|
- name: Build 4testing
|
||||||
run: |
|
run: |
|
||||||
DOCKER_TAG=$(echo ${{ steps.tag_name.outputs.SOURCE_TAG }} | sed 's/^.//' )
|
### ==>> At this step build variable declaration ###
|
||||||
PACKAGE_VERSION=$(echo $DOCKER_TAG | sed 's/\./-/3')
|
DOCKER_TAG=$( echo ${{ env.RELEASE_VERSION }} | sed 's/^.//' )
|
||||||
PACKAGE_URL=${{ secrets.REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_amd64.deb
|
PACKAGE_VERSION=$( echo $DOCKER_TAG | sed -E 's/(.*)\./\1-/' )
|
||||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" "$PACKAGE_URL")
|
NODE_PLATFORMS=$( echo ${{ steps.buildx.outputs.platforms }} | sed 's/linux\///g' | sed 's/,/ /g' )
|
||||||
if [[ "$STATUS" = "200" ]]; then
|
echo "Start check avalivable build platforms >>"
|
||||||
echo "Have access to documentserver${{ matrix.edition }} amd64 arch >> check arm64 access"
|
|
||||||
else
|
### ==>> In this loop we will check all avalivable documentserver architectures. After that all accessed arch will be added to build-platforms list. ###
|
||||||
echo "FAILED: Have no access to documentserver${{ matrix.edition }} amd64 arch"
|
for ARCH in ${NODE_PLATFORMS}; do
|
||||||
exit 1
|
REPO_URL=${{ secrets.REPO_URL }}
|
||||||
fi
|
if [[ ${{ env.RELEASE_VERSION }} == v99.* ]]; then
|
||||||
PACKAGE_URL=${{ secrets.REPO_URL }}${{ matrix.edition }}_"$PACKAGE_VERSION"_arm64.deb
|
REPO_URL=${{ secrets.UNSTABLE_REPO_URL }}
|
||||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" "$PACKAGE_URL")
|
fi
|
||||||
if [[ "$STATUS" = "200" ]]; then
|
PACKAGE_URL_CHECK=${REPO_URL}${{ matrix.edition }}_"$PACKAGE_VERSION"_${ARCH}.deb
|
||||||
echo "Have access to documentserver${{ matrix.edition }} arm64 arch"
|
STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" "${PACKAGE_URL_CHECK}")
|
||||||
echo "All architecture are available >> build is starting."
|
if [[ "$STATUS" = "200" ]]; then
|
||||||
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
|
echo "✔ ${ARCH} is avalivable >> set like one of build platforms"
|
||||||
PRODUCT_EDITION=${{ matrix.edition }} COMPANY_NAME=${{ env.COMPANY_NAME }} \
|
PLATFORMS+=(linux/${ARCH},)
|
||||||
PRODUCT_NAME=${{ env.PRODUCT_NAME }} DOCKERFILE=Dockerfile \
|
BUILD_PLATFORMS=$( echo ${PLATFORMS[@]} | sed 's/ //g' | sed 's/\(.*\),/\1/' )
|
||||||
PREFIX_NAME=4testing- TAG=$DOCKER_TAG \
|
else
|
||||||
docker buildx bake \
|
echo "${ARCH} in not avalivable"
|
||||||
-f docker-bake.hcl ${{ matrix.images }} \
|
fi
|
||||||
--push
|
done
|
||||||
echo "DONE: Build success >> exit with 0"
|
PACKAGE_URL_BUILD=$( echo ${PACKAGE_URL_CHECK} | sed -e "s/${PACKAGE_VERSION}_.*.deb/${PACKAGE_VERSION}_TARGETARCH.deb/g" )
|
||||||
exit 0
|
|
||||||
else
|
### ==>> At this step if there is no access to any platform and platform list is empty, build will exit with 1. ###
|
||||||
echo "FAILED: Have no access to some required architecture documentserver${{ matrix.edition }} >> Exit with 0."
|
if [[ -z ${BUILD_PLATFORMS} ]]; then
|
||||||
exit 1
|
echo "Have no access to any platform >> exit with 1"
|
||||||
|
exit 1
|
||||||
fi
|
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
|
shell: bash
|
||||||
|
|
|
@ -81,7 +81,8 @@ ENV COMPANY_NAME=$COMPANY_NAME \
|
||||||
PRODUCT_NAME=$PRODUCT_NAME \
|
PRODUCT_NAME=$PRODUCT_NAME \
|
||||||
PRODUCT_EDITION=$PRODUCT_EDITION
|
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 && \
|
apt-get -y update && \
|
||||||
service postgresql start && \
|
service postgresql start && \
|
||||||
apt-get -yq install /tmp/$(basename "$PACKAGE_URL") && \
|
apt-get -yq install /tmp/$(basename "$PACKAGE_URL") && \
|
||||||
|
|
|
@ -30,15 +30,25 @@ variable "DOCKERFILE" {
|
||||||
default = ""
|
default = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "PLATFORM" {
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "PACKAGE_URL" {
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
target "documentserver" {
|
target "documentserver" {
|
||||||
target = "documentserver"
|
target = "documentserver"
|
||||||
dockerfile= "${DOCKERFILE}"
|
dockerfile= "${DOCKERFILE}"
|
||||||
tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${TAG}"]
|
tags = ["docker.io/${COMPANY_NAME}/${PREFIX_NAME}${PRODUCT_NAME}${PRODUCT_EDITION}:${TAG}"]
|
||||||
platforms = ["linux/amd64", "linux/arm64"]
|
platforms = ["${PLATFORM}"]
|
||||||
args = {
|
args = {
|
||||||
"PRODUCT_EDITION": "${PRODUCT_EDITION}"
|
"PRODUCT_EDITION": "${PRODUCT_EDITION}"
|
||||||
"PRODUCT_NAME": "${PRODUCT_NAME}"
|
"PRODUCT_NAME": "${PRODUCT_NAME}"
|
||||||
"COMPANY_NAME": "${COMPANY_NAME}"
|
"COMPANY_NAME": "${COMPANY_NAME}"
|
||||||
|
"PACKAGE_URL": "{PACKAGE_URL}"
|
||||||
|
"PLATFORM": "${PLATFORM}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue