소스 검색

test(CI): use cache for build docker image

Signed-off-by: zhanghongtong <rory-z@outlook.com>
zhanghongtong 3 년 전
부모
커밋
62c3e7ce66
2개의 변경된 파일13개의 추가작업 그리고 19개의 파일을 삭제
  1. 11 1
      .github/workflows/build_base_image.yaml
  2. 2 18
      .github/workflows/build_packages.yaml

+ 11 - 1
.github/workflows/build_base_image.yaml

@@ -12,6 +12,7 @@ jobs:
 
   build:
     runs-on: ubuntu-latest
+    if: github.repository == 'lf-edge/ekuiper'
 
     strategy:
       fail-fast: false
@@ -29,6 +30,10 @@ jobs:
         with:
           image: tonistiigi/binfmt:latest
           platforms: all
+      - uses: actions/cache@v2
+        with:
+          path: /tmp/.docker-buildx-cache
+          key: docker-buildx-${{ matrix.golang }}-${{ matrix.os }}
       - name: Docker login
         uses: docker/login-action@v1
         with:
@@ -39,8 +44,13 @@ jobs:
         with:
           push: true
           pull: true
-          no-cache: true
+          cache-from: type=local,src=/tmp/.docker-buildx-cache,mode=max
+          cache-to: type=local,dest=/tmp/.docker-buildx-cache-new,mode=max
           platforms: linux/amd64,linux/arm64
           build-args: GO_VERSION=${{ matrix.golang }}
           tags: ghcr.io/${{ github.repository }}/base:${{ matrix.golang }}-${{ matrix.os }}
           file: .github/dockerfile/Dockerfile.${{ matrix.os }}
+      - name: Update cache
+        run: |
+          rm -rf /tmp/.docker-buildx-cache
+          mv /tmp/.docker-buildx-cache-new /tmp/.docker-buildx-cache

+ 2 - 18
.github/workflows/build_packages.yaml

@@ -38,29 +38,13 @@ jobs:
         image: tonistiigi/binfmt:latest
         platforms: all
     - uses: docker/setup-buildx-action@v1
-    - name: get docker sha256
-      id: disgest
-      run: |
-          digest=$(docker buildx imagetools inspect ghcr.io/${{ github.repository }}/base:${{ matrix.golang }}-${{ matrix.os }} --raw | jq --raw-output '.manifests[] | select(.platform.architecture=="amd64").digest')
-          echo "::set-output name=image::ghcr.io/${{ github.repository }}/base@${digest}"
-    - run: docker pull ${{ steps.disgest.outputs.image }}
-    - name: build base image
-      uses: docker/build-push-action@v2
-      with:
-        pull: true
-        load: true
-        cache-from: ${{ steps.disgest.outputs.image }}
-        platforms: ${{ matrix.arch }}
-        build-args: GO_VERSION=${{ matrix.golang }}
-        tags: ghcr.io/${{ github.repository }}/base:${{ matrix.golang }}-${{ matrix.os }}
-        file: .github/dockerfile/Dockerfile.${{ matrix.os }}
     - name: build
       run: |
         docker run -i --rm \
         -v $(pwd):/ekuiper \
         --workdir /ekuiper \
         --platform ${{ matrix.arch }} \
-        ghcr.io/${{ github.repository }}/base:${{ matrix.golang }}-${{ matrix.os }} \
+        ghcr.io/lf-edge/ekuiper/base:${{ matrix.golang }}-${{ matrix.os }} \
         bash -euc "make pkg  && .github/scripts/test.sh"
         cd _packages && for var in $(ls); do sudo bash -c "echo $(sha256sum $var | awk '{print $1}') > $var.sha256"; done && cd -
     - uses: actions/upload-artifact@v1
@@ -204,7 +188,7 @@ jobs:
             -v $(pwd):/ekuiper \
             --workdir /ekuiper \
             --platform ${{ matrix.arch }} \
-            ghcr.io/${{ github.repository }}/base:${{ matrix.golang }}-debian \
+            ghcr.io/lf-edge/ekuiper/base:${{ matrix.golang }}-debian \
             bash -euc "make ${{ matrix.plugin }}"
     - name: Build ekuiper image
       uses: docker/build-push-action@v2