From de0d1dc773c38c2885ca13e470e77d66cabb4a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Zimmermann?= Date: Mon, 13 Jan 2025 13:27:20 +0100 Subject: [PATCH] fix build and push action --- .github/workflows/container-build.yml | 123 +++++++++++++------------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/.github/workflows/container-build.yml b/.github/workflows/container-build.yml index 6341a0340..1371275bc 100644 --- a/.github/workflows/container-build.yml +++ b/.github/workflows/container-build.yml @@ -69,7 +69,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: - driver: remote + driver: docker-container platforms: linux/amd64 append: | - endpoint: ssh://root@${{ secrets.DOCKER_BUILD_SERVER_01 }} @@ -86,68 +86,67 @@ jobs: build-args: | LOGPREP_VERSION=${{ inputs.build-version }} PYTHON_VERSION=${{ matrix.python-version }} - tags: ${{ steps.image-tag.outputs.tags }} - platforms: "linux/arm64,linux/amd64" tags: ${{ steps.image-tag.outputs.tags }} + platforms: "linux/arm64,linux/amd64" cache-from: type=gha cache-to: type=gha,mode=max - # - name: Extract image ID from sha256 - # id: pushed-imageid - # run: | - # python - <> $GITHUB_OUTPUT - - # - name: Restore trivy cache - # uses: actions/cache@v4 - # with: - # path: cache/db - # key: trivy-cache-${{ steps.date.outputs.date }} - # restore-keys: trivy-cache- - - # - name: Scan image using Trivy - # uses: aquasecurity/trivy-action@0.24.0 - # env: - # TRIVY_CACHE_DIR: ./cache - # TRIVY_PLATFORM: linux/amd64 - # with: - # scan-type: image - # image-ref: ghcr.io/fkie-cad/logprep@${{ steps.build-and-push.outputs.digest }} - # trivy-config: trivy.yaml - - # # Trivy-db uses `0600` permissions. - # # But `action/cache` use `runner` user by default - # # So we need to change the permissions before caching the database. - # - name: Change permissions for trivy.db - # run: sudo chmod 0644 ./cache/db/trivy.db + - name: Extract image ID from sha256 + id: pushed-imageid + run: | + python - <> $GITHUB_OUTPUT + + - name: Restore trivy cache + uses: actions/cache@v4 + with: + path: cache/db + key: trivy-cache-${{ steps.date.outputs.date }} + restore-keys: trivy-cache- + + - name: Scan image using Trivy + uses: aquasecurity/trivy-action@0.24.0 + env: + TRIVY_CACHE_DIR: ./cache + TRIVY_PLATFORM: linux/amd64 + with: + scan-type: image + image-ref: ghcr.io/fkie-cad/logprep@${{ steps.build-and-push.outputs.digest }} + trivy-config: trivy.yaml + + # Trivy-db uses `0600` permissions. + # But `action/cache` use `runner` user by default + # So we need to change the permissions before caching the database. + - name: Change permissions for trivy.db + run: sudo chmod 0644 ./cache/db/trivy.db