From 4203dafe94fdf3643c4459e1f6a7767ed1a0eb57 Mon Sep 17 00:00:00 2001 From: Valeria Bagisheva Date: Thu, 18 Jul 2024 16:30:38 +0300 Subject: [PATCH 1/6] Add customize for branch and commit --- install/docker/Dockerfile.app | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/install/docker/Dockerfile.app b/install/docker/Dockerfile.app index 00b869091ef..96d4b3588c4 100644 --- a/install/docker/Dockerfile.app +++ b/install/docker/Dockerfile.app @@ -16,6 +16,15 @@ ARG DEPLOY_ARGS="deploy" ARG DEBUG_INFO="true" ARG PUBLISH_CNF="Release" +ARG BUILDTOOLS_BRANCH="" +ARG SERVER_BRANCH="" +ARG CLIENT_BRANCH="" +ARG CAMPAIGNS_BRANCH="" +ARG BUILDTOOLS_COMMIT="" +ARG SERVER_COMMIT="" +ARG CLIENT_COMMIT="" +ARG CAMPAIGNS_COMMIT="" + LABEL onlyoffice.appserver.release-date="${RELEASE_DATE}" \ maintainer="Ascensio System SIA " @@ -23,6 +32,11 @@ ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US:en \ LC_ALL=en_US.UTF-8 +ENV BUILDTOOLS_BRANCH=${BUILDTOOLS_BRANCH:-$GIT_BRANCH} +ENV SERVER_BRANCH=${SERVER_BRANCH:-$GIT_BRANCH} +ENV CLIENT_BRANCH=${CLIENT_BRANCH:-$GIT_BRANCH} +ENV CAMPAIGNS_BRANCH=${CAMPAIGNS_BRANCH:-$GIT_BRANCH} + RUN apt-get -y update && \ apt-get install -yq \ sudo \ @@ -40,10 +54,14 @@ RUN apt-get -y update && \ rm -rf /var/lib/apt/lists/* ADD https://api.github.com/repos/ONLYOFFICE/DocSpace-buildtools/git/refs/heads/${GIT_BRANCH} version.json -RUN git clone -b ${GIT_BRANCH} https://github.com/ONLYOFFICE/DocSpace-buildtools.git ${SRC_PATH}/buildtools && \ - git clone --recurse-submodules -b ${GIT_BRANCH} https://github.com/ONLYOFFICE/DocSpace-Server.git ${SRC_PATH}/server && \ - git clone -b ${GIT_BRANCH} https://github.com/ONLYOFFICE/DocSpace-Client.git ${SRC_PATH}/client && \ - git clone -b "master" --depth 1 https://github.com/ONLYOFFICE/ASC.Web.Campaigns.git ${SRC_PATH}/campaigns +RUN git clone -b ${BUILDTOOLS_BRANCH} https://github.com/lemmav/DocSpace-buildtools.git ${SRC_PATH}/buildtools && \ + if [ -n "${BUILDTOOLS_COMMIT}" ]; then git -C ${SRC_PATH}/buildtools checkout ${BUILDTOOLS_COMMIT}; fi && \ + git clone --recurse-submodules -b ${SERVER_BRANCH} https://github.com/ONLYOFFICE/DocSpace-Server.git ${SRC_PATH}/server && \ + if [ -n "${SERVER_COMMIT}" ]; then git -C ${SRC_PATH}/server checkout ${SERVER_COMMIT}; fi && \ + git clone -b ${CLIENT_BRANCH} https://github.com/ONLYOFFICE/DocSpace-Client.git ${SRC_PATH}/client && \ + if [ -n "${CLIENT_COMMIT}" ]; then git -C ${SRC_PATH}/client checkout ${CLIENT_COMMIT}; fi && \ + git clone -b master --depth 1 https://github.com/ONLYOFFICE/ASC.Web.Campaigns.git ${SRC_PATH}/campaigns && \ + if [ -n "${CAMPAIGNS_COMMIT}" ]; then git -C ${SRC_PATH}/campaigns checkout ${CAMPAIGNS_COMMIT}; fi RUN cd ${SRC_PATH} && \ mkdir -p /app/onlyoffice/config/ && \ From f95931cf4fa1836f85a23b6b6526cf1cafb657b3 Mon Sep 17 00:00:00 2001 From: Valeria Bagisheva Date: Thu, 18 Jul 2024 16:31:19 +0300 Subject: [PATCH 2/6] Get branch from docker environment variable --- debuginfo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/debuginfo.py b/debuginfo.py index a6fc574dcd1..6e21bd20773 100755 --- a/debuginfo.py +++ b/debuginfo.py @@ -30,9 +30,11 @@ def fetchCommits(url, type): print("Error folder does not exists", path) return + branch_env = f"{type.upper()}_BRANCH" + branch = os.environ.get(branch_env) repo = Repo(path) - info = f"| [DocSpace-{type}]({url}) | [{repo.active_branch.name}]({url}/tree/{repo.active_branch.name}) | [{repo.head.commit}]({url}/commit/{repo.head.commit}) |{os.linesep}" + info = f"| [DocSpace-{type}]({url}) | [{branch}]({url}/tree/{branch}) | [{repo.head.commit}]({url}/commit/{repo.head.commit}) |{os.linesep}" commits_str = repo.git.log(f"--pretty=format: {format}", "--no-merges", f"--since={LIMIT_DAYS}.days") #print(commits_str) From 6afcf4c6ff298cc1968d6c3fe3915203c6e4650f Mon Sep 17 00:00:00 2001 From: Valeria Bagisheva <104082183+lemmav@users.noreply.github.com> Date: Sun, 21 Jul 2024 18:54:19 +0300 Subject: [PATCH 3/6] Change repo name in git lone --- install/docker/Dockerfile.app | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/docker/Dockerfile.app b/install/docker/Dockerfile.app index 96d4b3588c4..d27b340a3b7 100644 --- a/install/docker/Dockerfile.app +++ b/install/docker/Dockerfile.app @@ -54,7 +54,7 @@ RUN apt-get -y update && \ rm -rf /var/lib/apt/lists/* ADD https://api.github.com/repos/ONLYOFFICE/DocSpace-buildtools/git/refs/heads/${GIT_BRANCH} version.json -RUN git clone -b ${BUILDTOOLS_BRANCH} https://github.com/lemmav/DocSpace-buildtools.git ${SRC_PATH}/buildtools && \ +RUN git clone -b ${BUILDTOOLS_BRANCH} https://github.com/ONLYOFFICE/DocSpace-buildtools.git ${SRC_PATH}/buildtools && \ if [ -n "${BUILDTOOLS_COMMIT}" ]; then git -C ${SRC_PATH}/buildtools checkout ${BUILDTOOLS_COMMIT}; fi && \ git clone --recurse-submodules -b ${SERVER_BRANCH} https://github.com/ONLYOFFICE/DocSpace-Server.git ${SRC_PATH}/server && \ if [ -n "${SERVER_COMMIT}" ]; then git -C ${SRC_PATH}/server checkout ${SERVER_COMMIT}; fi && \ From 266221b6e073ae0f8fe8353924ceda184942bf05 Mon Sep 17 00:00:00 2001 From: Valeria Bagisheva Date: Tue, 23 Jul 2024 13:55:30 +0300 Subject: [PATCH 4/6] Add build from last commits --- .github/workflows/cron-build.yml | 24 +++++++++++++++++++++++- .github/workflows/main-build.yml | 9 +++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cron-build.yml b/.github/workflows/cron-build.yml index 18255dd9ac7..55c58c8382a 100644 --- a/.github/workflows/cron-build.yml +++ b/.github/workflows/cron-build.yml @@ -18,10 +18,29 @@ jobs: run: | all_branches=$(git ls-remote -hq | sed -n 's/^[0-9a-f]\{40\}\s\+refs\/heads\//''/p') matching_branches="" + hashes="" for branch in $all_branches; do if [[ $branch =~ ^release/v[0-9]+ || $branch =~ ^hotfix/v[0-9]+ || $branch == "develop" ]]; then matching_branches="${matching_branches},\"${branch}\"" + curl_buildtools=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/ONLYOFFICE/DocSpace-buildtools/commits/${branch}" | jq -r '.sha') + + curl_client=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/ONLYOFFICE/DocSpace-client/commits/${branch}" | jq -r '.sha') + + curl_server=$(curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/ONLYOFFICE/DocSpace-server/commits/${branch}" | jq -r '.sha') + + echo "${branch}_buildtools_hash=${curl_buildtools}" >> $GITHUB_ENV + echo "${branch}_client_hash=${curl_client}" >> $GITHUB_ENV + echo "${branch}_server_hash=${curl_server}" >> $GITHUB_ENV fi done @@ -35,12 +54,15 @@ jobs: run: | echo "${{ steps.list-branches.outputs.json_output }}" + payload=$((env | grep '_hash=' | awk -F'=' '{print "\"" $1 "\": \"" $2 "\""}' | paste -sd, - | sed 's/^/{/;s/$/}/')| tr -d '[:space:]') + echo "Payload JSON: $payload" + curl \ -X POST \ -u "${{ secrets.USERNAME}}:${{secrets.TOKEN}}" \ "https://api.github.com/repos/ONLYOFFICE/DocSpace-buildtools/dispatches" \ -H "Accept: application/vnd.github.everest-preview+json" \ - --data '{"event_type": "cron-trigger-action", "client_payload": { "branches": ${{ steps.list-branches.outputs.json_output }}}}' + --data '{"event_type": "cron-trigger-action", "client_payload": { "branches": ${{ steps.list-branches.outputs.json_output }}, "hashes": '$payload' } }' curl \ -X POST \ diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml index db31fe585f9..33763d4f2ab 100644 --- a/.github/workflows/main-build.yml +++ b/.github/workflows/main-build.yml @@ -62,6 +62,12 @@ jobs: DOCKER_TAG=${PRODUCT_VERSION}.${{github.run_number}} fi export DOCKER_TAG + BUILDTOOLS_ENV="${{ github.event.client_payload.hashes[ format('{0}_buildtools_hash', matrix.branch)] }}" + SERVER_ENV="${{ github.event.client_payload.hashes[ format('{0}_server_hash', matrix.branch)] }}" + CLIENT_ENV="${{ github.event.client_payload.hashes[ format('{0}_client_hash', matrix.branch)] }}" + echo "buildtools_hash: $BUILDTOOLS_ENV" + echo "server_hash: $SERVER_ENV" + echo "client_hash: $CLIENT_ENV" docker buildx bake -f build.yml \ --set *.args.GIT_BRANCH=${{ matrix.branch }} \ --set *.args.PRODUCT_VERSION=${PRODUCT_VERSION} \ @@ -69,6 +75,9 @@ jobs: --set *.platform=linux/amd64 \ --set *.args.PRODUCT_VERSION=${PRODUCT_VERSION} \ --set *.args.BUILD_NUMBER=${{github.run_number}} \ + --set *.args.BUILDTOOLS_COMMIT=$BUILDTOOLS_ENV \ + --set *.args.SERVER_COMMIT=$SERVER_ENV \ + --set *.args.CLIENT_COMMIT=$CLIENT_ENV \ --push echo "version=${DOCKER_TAG}" >> "$GITHUB_OUTPUT" From bfbb2e18ebef7f41e940c8da788fc29d7157d86a Mon Sep 17 00:00:00 2001 From: Valeria Bagisheva Date: Wed, 24 Jul 2024 18:26:46 +0300 Subject: [PATCH 5/6] Refactor to use ARG for setting BUILDTOOLS_BRANCH --- install/docker/Dockerfile.app | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install/docker/Dockerfile.app b/install/docker/Dockerfile.app index d27b340a3b7..dd077de12b2 100644 --- a/install/docker/Dockerfile.app +++ b/install/docker/Dockerfile.app @@ -32,10 +32,10 @@ ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US:en \ LC_ALL=en_US.UTF-8 -ENV BUILDTOOLS_BRANCH=${BUILDTOOLS_BRANCH:-$GIT_BRANCH} -ENV SERVER_BRANCH=${SERVER_BRANCH:-$GIT_BRANCH} -ENV CLIENT_BRANCH=${CLIENT_BRANCH:-$GIT_BRANCH} -ENV CAMPAIGNS_BRANCH=${CAMPAIGNS_BRANCH:-$GIT_BRANCH} +ARG BUILDTOOLS_BRANCH=${BUILDTOOLS_BRANCH:-$GIT_BRANCH} +ARG SERVER_BRANCH=${SERVER_BRANCH:-$GIT_BRANCH} +ARG CLIENT_BRANCH=${CLIENT_BRANCH:-$GIT_BRANCH} +ARG CAMPAIGNS_BRANCH=${CAMPAIGNS_BRANCH:-$GIT_BRANCH} RUN apt-get -y update && \ apt-get install -yq \ @@ -53,7 +53,7 @@ RUN apt-get -y update && \ apt-get install -y nodejs && \ rm -rf /var/lib/apt/lists/* -ADD https://api.github.com/repos/ONLYOFFICE/DocSpace-buildtools/git/refs/heads/${GIT_BRANCH} version.json +ADD https://api.github.com/repos/ONLYOFFICE/DocSpace-buildtools/git/refs/heads/${BUILDTOOLS_BRANCH} version.json RUN git clone -b ${BUILDTOOLS_BRANCH} https://github.com/ONLYOFFICE/DocSpace-buildtools.git ${SRC_PATH}/buildtools && \ if [ -n "${BUILDTOOLS_COMMIT}" ]; then git -C ${SRC_PATH}/buildtools checkout ${BUILDTOOLS_COMMIT}; fi && \ git clone --recurse-submodules -b ${SERVER_BRANCH} https://github.com/ONLYOFFICE/DocSpace-Server.git ${SRC_PATH}/server && \ From c80e895b9e4ce941b3fe428a5f5090853fc0371f Mon Sep 17 00:00:00 2001 From: Valeria Bagisheva Date: Thu, 25 Jul 2024 14:09:34 +0300 Subject: [PATCH 6/6] Unify names of environment variables for branches --- install/docker/Dockerfile.app | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/install/docker/Dockerfile.app b/install/docker/Dockerfile.app index dd077de12b2..2c9927b0c8e 100644 --- a/install/docker/Dockerfile.app +++ b/install/docker/Dockerfile.app @@ -16,10 +16,10 @@ ARG DEPLOY_ARGS="deploy" ARG DEBUG_INFO="true" ARG PUBLISH_CNF="Release" -ARG BUILDTOOLS_BRANCH="" -ARG SERVER_BRANCH="" -ARG CLIENT_BRANCH="" -ARG CAMPAIGNS_BRANCH="" +ARG GIT_BRANCH_BUILDTOOLS="" +ARG GIT_BRANCH_SERVER="" +ARG GIT_BRANCH_CLIENT="" +ARG GIT_BRANCH_CAMPAIGNS="" ARG BUILDTOOLS_COMMIT="" ARG SERVER_COMMIT="" ARG CLIENT_COMMIT="" @@ -32,10 +32,10 @@ ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US:en \ LC_ALL=en_US.UTF-8 -ARG BUILDTOOLS_BRANCH=${BUILDTOOLS_BRANCH:-$GIT_BRANCH} -ARG SERVER_BRANCH=${SERVER_BRANCH:-$GIT_BRANCH} -ARG CLIENT_BRANCH=${CLIENT_BRANCH:-$GIT_BRANCH} -ARG CAMPAIGNS_BRANCH=${CAMPAIGNS_BRANCH:-$GIT_BRANCH} +ARG GIT_BRANCH_BUILDTOOLS=${GIT_BRANCH_BUILDTOOLS:-$GIT_BRANCH} +ARG GIT_BRANCH_SERVER=${GIT_BRANCH_SERVER:-$GIT_BRANCH} +ARG GIT_BRANCH_CLIENT=${GIT_BRANCH_CLIENT:-$GIT_BRANCH} +ARG GIT_BRANCH_CAMPAIGNS=${GIT_BRANCH_CAMPAIGNS:-$GIT_BRANCH} RUN apt-get -y update && \ apt-get install -yq \ @@ -53,12 +53,12 @@ RUN apt-get -y update && \ apt-get install -y nodejs && \ rm -rf /var/lib/apt/lists/* -ADD https://api.github.com/repos/ONLYOFFICE/DocSpace-buildtools/git/refs/heads/${BUILDTOOLS_BRANCH} version.json -RUN git clone -b ${BUILDTOOLS_BRANCH} https://github.com/ONLYOFFICE/DocSpace-buildtools.git ${SRC_PATH}/buildtools && \ +ADD https://api.github.com/repos/ONLYOFFICE/DocSpace-buildtools/git/refs/heads/${GIT_BRANCH_BUILDTOOLS} version.json +RUN git clone -b ${GIT_BRANCH_BUILDTOOLS} https://github.com/ONLYOFFICE/DocSpace-buildtools.git ${SRC_PATH}/buildtools && \ if [ -n "${BUILDTOOLS_COMMIT}" ]; then git -C ${SRC_PATH}/buildtools checkout ${BUILDTOOLS_COMMIT}; fi && \ git clone --recurse-submodules -b ${SERVER_BRANCH} https://github.com/ONLYOFFICE/DocSpace-Server.git ${SRC_PATH}/server && \ if [ -n "${SERVER_COMMIT}" ]; then git -C ${SRC_PATH}/server checkout ${SERVER_COMMIT}; fi && \ - git clone -b ${CLIENT_BRANCH} https://github.com/ONLYOFFICE/DocSpace-Client.git ${SRC_PATH}/client && \ + git clone -b ${GIT_BRANCH_CLIENT} https://github.com/ONLYOFFICE/DocSpace-Client.git ${SRC_PATH}/client && \ if [ -n "${CLIENT_COMMIT}" ]; then git -C ${SRC_PATH}/client checkout ${CLIENT_COMMIT}; fi && \ git clone -b master --depth 1 https://github.com/ONLYOFFICE/ASC.Web.Campaigns.git ${SRC_PATH}/campaigns && \ if [ -n "${CAMPAIGNS_COMMIT}" ]; then git -C ${SRC_PATH}/campaigns checkout ${CAMPAIGNS_COMMIT}; fi