You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by he...@apache.org on 2022/07/08 07:46:29 UTC

[inlong] branch master updated: [INLONG-4910][CI] Build arm images only on the release branch (#4911)

This is an automated email from the ASF dual-hosted git repository.

healchow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 7d64551a8 [INLONG-4910][CI] Build arm images only on the release branch (#4911)
7d64551a8 is described below

commit 7d64551a8d371b0b2301f513563c18ef08e8b74e
Author: Lucas <10...@users.noreply.github.com>
AuthorDate: Fri Jul 8 15:46:24 2022 +0800

    [INLONG-4910][CI] Build arm images only on the release branch (#4911)
    
    * Change build arm images only on the release branch
    
    * Add publish arm images
    
    * Update docker workflow
    
    * Add x86 support when the master branch changes
    
    Co-authored-by: Yuanhao Ji <ji...@apache.org>
---
 .github/workflows/ci_docker.yml | 47 +++++++++++++++++------------------------
 docker/build-docker-images.sh   |  2 +-
 docker/publish-by-arch.sh       |  9 ++++----
 3 files changed, 24 insertions(+), 34 deletions(-)

diff --git a/.github/workflows/ci_docker.yml b/.github/workflows/ci_docker.yml
index 7bf96bd00..07b865a02 100644
--- a/.github/workflows/ci_docker.yml
+++ b/.github/workflows/ci_docker.yml
@@ -79,57 +79,48 @@ jobs:
         env:
           CI: false
 
-      # Check if only the workflow file is changed.
-      - name: Check workflow diff
-        id: check-workflow-diff
-        uses: apache/pulsar-test-infra/diff-only@master
-        with:
-          args: .github/workflows/ci_docker.yml
-
-      # If the changes are being pushed to the master branch or a branch like 'release-1.0.0', this step will output true.
       - name: Match branch
-        id: match-branch
+        id: match
         if: |
           success()
           && github.event_name == 'push'
           && github.repository_owner == 'apache'
         run: |
-          if [[ ${{ github.ref_name }} == ${{ github.event.repository.default_branch }} || ${{ github.ref_name }} =~ ^release-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
-              echo "::set-output name=match::true"
+          if [[ ${{ github.ref_name }} == ${{ github.event.repository.default_branch }} ]]; then
+            echo "::set-output name=match_master::true"
+          elif [[ ${{ github.ref_name }} =~ ^release-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+            echo "::set-output name=match_release::true"
           fi
 
-      # If only this workflow file is changed, there is no need to publish Docker images.
+      # Publish x86 Docker images when the changes are being pushed to the master branch or a release branch like 'release-1.0.0'.
       - name: Push x86 Docker images to Docker Hub
         if: |
-          success()
-          && steps.check-workflow-diff.outputs.changed_only == 'no'
-          && steps.match-branch.outputs.match == 'true'
+          steps.match.outputs.match_master == 'true'
+          || steps.match.outputs.match_release == 'true'
         working-directory: docker
-        run: bash +x publish-by-arch.sh --tag --publish
+        run: |
+          bash +x publish-by-arch.sh --tag --publish
         env:
           DOCKER_USER: ${{ secrets.DOCKER_USER }}
           DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
 
-      # If only this workflow file is changed, there is no need to publish Docker images.
+      # Publish aarch64 Docker images when the changes are being pushed to a release branch like 'release-1.0.0'.
       - name: Push aarch64 Docker images to Docker Hub
-        if: |
-          success()
-          && steps.check-workflow-diff.outputs.changed_only == 'no'
-          && steps.match-branch.outputs.match == 'true'
+        if: ${{ steps.match.outputs.match_release == 'true' }}
         working-directory: docker
-        run: bash +x publish-by-arch.sh --tag --buildx aarch64 --publish
+        run: |
+          bash +x build-docker-images.sh --buildx aarch64
+          bash +x publish-by-arch.sh --tag --arch aarch64 --publish
         env:
           DOCKER_USER: ${{ secrets.DOCKER_USER }}
           DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
 
-      # If only this workflow file is changed, there is no need to publish Docker images.
+      # Push manifest after publishing aarch64 Docker images.
       - name: Push manifest to Docker Hub
-        if: |
-          success()
-          && steps.check-workflow-diff.outputs.changed_only == 'no'
-          && steps.match-branch.outputs.match == 'true'
+        if: ${{ steps.match.outputs.match_release == 'true' }}
         working-directory: docker
-        run: bash +x publish-by-arch.sh --manifest
+        run: |
+          bash +x publish-by-arch.sh --manifest
         env:
           DOCKER_USER: ${{ secrets.DOCKER_USER }}
           DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
diff --git a/docker/build-docker-images.sh b/docker/build-docker-images.sh
index 11fc388c3..18e3fc51a 100644
--- a/docker/build-docker-images.sh
+++ b/docker/build-docker-images.sh
@@ -69,7 +69,7 @@ for (( i=1; i<=$#; i++)); do
 done
 
 if [ "$BUILD_ARCH" = "$ARCH_X86" ] && [ "$ENV_ARCH" = "$ARCH_X86" ]; then
-  mvn clean install -DskipTests -Pdocker
+  mvn --batch-mode --update-snapshots -e -V clean package -DskipTests -Pdocker
   exit 0
 fi
 
diff --git a/docker/publish-by-arch.sh b/docker/publish-by-arch.sh
index a17952b80..12b373b72 100644
--- a/docker/publish-by-arch.sh
+++ b/docker/publish-by-arch.sh
@@ -40,9 +40,9 @@ buildImage() {
   cd "${SHELL_FOLDER}"
   cd ..
   if [ "$BUILD_ARCH" = "$ARCH_X86" ] && [ "$ENV_ARCH" = "$ARCH_X86" ]; then
-    mvn clean install -DskipTests -Pdocker
+    mvn --batch-mode --update-snapshots -e -V clean package -DskipTests -Pdocker
   else
-    mvn clean install -DskipTests
+    mvn --batch-mode --update-snapshots -e -V clean package -DskipTests
     sh ./docker/build-docker-images.sh ${USE_BUILDX} ${BUILD_ARCH}
   fi
   echo "End building images"
@@ -254,7 +254,7 @@ Options:
   -t, --tag             Add tag operation before publish. Add arch after version and add docker registry org.
   -p, --publish         Publish images according to docker registry information.
   -m, --manifest        Push manifest. This option doesn't need arch.
-  -x, --buildx <ARCH>   Use buildx to build docker images for another arch. This option doesn't need -b.
+  -a, --arch <ARCH>     Use buildx to build docker images for another arch.
                         Arch must be provided, as aarch64 or x86.
   -h, --help            Show help information.
 Example:
@@ -273,8 +273,7 @@ for (( i=1; i<="$#"; i++)); do
     NEED_MANIFEST=true
   elif [ "${!i}" = "-p" ] || [ "${!i}" = "--publish" ]; then
     NEED_PUBLISH=true
-  elif [ "${!i}" = "-x" ] || [ "${!i}" = "--buildx" ]; then
-    NEED_BUILD=true
+  elif [ "${!i}" = "-a" ] || [ "${!i}" = "--arch" ]; then
     USE_BUILDX="--buildx"
     j=$((i+1))
     BUILD_ARCH=${!j}