From 5c9d3b7683537d48a4121b049e8949331c788c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 02:29:48 +0000 Subject: [PATCH 01/15] Use docker/metadata-action in deploy-DEV workflow --- .github/workflows/deploy-DEV.yml | 78 +++++++++++++------------------- 1 file changed, 31 insertions(+), 47 deletions(-) diff --git a/.github/workflows/deploy-DEV.yml b/.github/workflows/deploy-DEV.yml index 93f9fb3e74e..4aa0da40946 100644 --- a/.github/workflows/deploy-DEV.yml +++ b/.github/workflows/deploy-DEV.yml @@ -61,37 +61,15 @@ jobs: # Load all steps # ################## steps: - ########################## - # Checkout the code base # - ########################## - name: Checkout Code uses: actions/checkout@v4 - ####################### - # Docker Buildx setup # - ####################### - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - ######################## - # Get the current date # - ######################## - - name: Get current date - run: echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >>"$GITHUB_ENV" - - ######################## - # Build image tag name # - ######################## - - name: Build image tag name - id: image_tag - run: | - BRANCH_NAME="${GITHUB_REF##*/}" - TAG="test-${{ github.actor }}-${BRANCH_NAME}" - echo "Tag name: ${TAG}" - echo "tag=${TAG}" >>"$GITHUB_OUTPUT" + - name: Docker Metadata action + uses: docker/metadata-action@v5.3.0 + id: meta + with: + images: | + ${{ github.repository }} - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -118,16 +96,18 @@ jobs: file: Dockerfile-quick platforms: linux/amd64 build-args: | - BUILD_DATE=${{ env.BUILD_DATE }} - BUILD_REVISION=${{ github.sha }} - BUILD_VERSION=${{ steps.image_tag.outputs.tag }} + BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} + BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} + BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} MEGA_LINTER_BASE_IMAGE="oxsecurity/megalinter:beta" load: true push: false secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} - tags: | - oxsecurity/megalinter:${{ steps.image_tag.outputs.tag }} + tags: ${{ steps.meta.outputs.tags }} + annotations: ${{ steps.meta.outputs.annotations }} + provenance: true + sbom: true timeout-minutes: 90 ####################################### @@ -148,15 +128,17 @@ jobs: file: Dockerfile platforms: linux/amd64 build-args: | - BUILD_DATE=${{ env.BUILD_DATE }} - BUILD_REVISION=${{ github.sha }} - BUILD_VERSION=${{ steps.image_tag.outputs.tag }} + BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} + BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} + BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} load: true push: false secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} - tags: | - oxsecurity/megalinter:${{ steps.image_tag.outputs.tag }} + tags: ${{ steps.meta.outputs.tags }} + annotations: ${{ steps.meta.outputs.annotations }} + provenance: true + sbom: true timeout-minutes: 90 #################################### @@ -176,15 +158,17 @@ jobs: file: Dockerfile platforms: linux/amd64 build-args: | - BUILD_DATE=${{ env.BUILD_DATE }} - BUILD_REVISION=${{ github.sha }} - BUILD_VERSION=${{ steps.image_tag.outputs.tag }} + BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} + BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} + BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} load: true push: false secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} - tags: | - oxsecurity/megalinter:${{ steps.image_tag.outputs.tag }} + tags: ${{ steps.meta.outputs.tags }} + annotations: ${{ steps.meta.outputs.annotations }} + provenance: true + sbom: true # Clean docker build cache - name: Clean docker buildx cache @@ -211,7 +195,7 @@ jobs: fi fi docker image ls - docker run $CI_ENV -e TEST_CASE_RUN=true -e OUTPUT_FORMAT=text -e OUTPUT_FOLDER=${{ github.sha }} -e OUTPUT_DETAIL=detailed -e GITHUB_SHA=${{ github.sha }} -e GITHUB_REPOSITORY=${GITHUB_REPOSITORY} -e GITHUB_BRANCH=${GITHUB_BRANCH} -e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -e TEST_KEYWORDS="${TEST_KEYWORDS_TO_USE}" -e MEGALINTER_VOLUME_ROOT="${GITHUB_WORKSPACE}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v ${GITHUB_WORKSPACE}:/tmp/lint oxsecurity/megalinter:${{ steps.image_tag.outputs.tag }} + docker run $CI_ENV -e TEST_CASE_RUN=true -e OUTPUT_FORMAT=text -e OUTPUT_FOLDER=${{ github.sha }} -e OUTPUT_DETAIL=detailed -e GITHUB_SHA=${{ github.sha }} -e GITHUB_REPOSITORY=${GITHUB_REPOSITORY} -e GITHUB_BRANCH=${GITHUB_BRANCH} -e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -e TEST_KEYWORDS="${TEST_KEYWORDS_TO_USE}" -e MEGALINTER_VOLUME_ROOT="${GITHUB_WORKSPACE}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v ${GITHUB_WORKSPACE}:/tmp/lint ${{ fromJson(steps.meta.outputs.json).tags[0]}} timeout-minutes: 90 ##################################### @@ -220,7 +204,7 @@ jobs: - name: Run against all code base if: "!contains(github.event.head_commit.message, 'quick build')" shell: bash - run: docker run -e GITHUB_REPOSITORY="${{ github.repository }}" -e GITHUB_SHA="${{ github.sha }}" -e GITHUB_TOKEN="${{ github.token }}" -e GITHUB_RUN_ID="${{ github.run_id }}" -e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v ${GITHUB_WORKSPACE}:/tmp/lint oxsecurity/megalinter:${{ steps.image_tag.outputs.tag }} + run: docker run -e GITHUB_REPOSITORY="${{ github.repository }}" -e GITHUB_SHA="${{ github.sha }}" -e GITHUB_TOKEN="${{ github.token }}" -e GITHUB_RUN_ID="${{ github.run_id }}" -e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v ${GITHUB_WORKSPACE}:/tmp/lint ${{ fromJson(steps.meta.outputs.json).tags[0]}} timeout-minutes: 15 # Upload MegaLinter artifacts @@ -259,7 +243,7 @@ jobs: run: cd mega-linter-runner && sudo yarn install --frozen-lockfile && sudo npm link - name: Run mega-linter-runner tests if: ${{ steps.docker_build.outcome }} == 'success' && !contains(github.event.head_commit.message, 'quick build') - run: cd mega-linter-runner && MEGALINTER_RELEASE=${{ steps.image_tag.outputs.tag }} MEGALINTER_NO_DOCKER_PULL=true npm run test + run: cd mega-linter-runner && MEGALINTER_RELEASE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} MEGALINTER_NO_DOCKER_PULL=true npm run test # - name: free disk space # run: | @@ -274,7 +258,7 @@ jobs: # - name: Run Trivy vulnerability scanner # uses: aquasecurity/trivy-action@master # with: - # image-ref: "docker.io/oxsecurity/megalinter:${{ steps.image_tag.outputs.tag }}" + # image-ref: "docker.io/${{ fromJson(steps.meta.outputs.json).tags[0]}}" # format: 'table' # exit-code: '1' # ignore-unfixed: true From b8f8926a600e0c57279aa73f4c20d3dba7312374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 02:30:41 +0000 Subject: [PATCH 02/15] Add options to docker/build-push-action --- .github/workflows/deploy-DEV-linters.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index 0e1b7872dd0..c05f17a0ab6 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -219,6 +219,9 @@ jobs: secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} tags: ${{ steps.meta.outputs.tags }} + annotations: ${{ steps.meta.outputs.annotations }} + provenance: true + sbom: true ##################################### # Run Linter test cases # From 36d37965e4dc0a3f00b1af95700cac921bbf907a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 02:38:01 +0000 Subject: [PATCH 03/15] Fix workflow indentation --- .github/workflows/deploy-DEV.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-DEV.yml b/.github/workflows/deploy-DEV.yml index 4aa0da40946..da50d058b99 100644 --- a/.github/workflows/deploy-DEV.yml +++ b/.github/workflows/deploy-DEV.yml @@ -204,7 +204,7 @@ jobs: - name: Run against all code base if: "!contains(github.event.head_commit.message, 'quick build')" shell: bash - run: docker run -e GITHUB_REPOSITORY="${{ github.repository }}" -e GITHUB_SHA="${{ github.sha }}" -e GITHUB_TOKEN="${{ github.token }}" -e GITHUB_RUN_ID="${{ github.run_id }}" -e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v ${GITHUB_WORKSPACE}:/tmp/lint ${{ fromJson(steps.meta.outputs.json).tags[0]}} + run: docker run -e GITHUB_REPOSITORY="${{ github.repository }}" -e GITHUB_SHA="${{ github.sha }}" -e GITHUB_TOKEN="${{ github.token }}" -e GITHUB_RUN_ID="${{ github.run_id }}" -e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v ${GITHUB_WORKSPACE}:/tmp/lint ${{ fromJson(steps.meta.outputs.json).tags[0]}} timeout-minutes: 15 # Upload MegaLinter artifacts From 507e1e8c62608b9fe3cfb3cc0e15facfd5d81d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 03:11:31 +0000 Subject: [PATCH 04/15] set output type image --- .github/workflows/deploy-DEV-linters.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index c05f17a0ab6..3061bd27b51 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -222,6 +222,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true + output: type=image ##################################### # Run Linter test cases # From e24c198daa729b7b2bcf4557cbd47569b4147567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 03:13:12 +0000 Subject: [PATCH 05/15] Typo in outputs --- .github/workflows/deploy-DEV-linters.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index 3061bd27b51..c72abe2147d 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -222,7 +222,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true - output: type=image + outputs: type=image ##################################### # Run Linter test cases # From 246b9bd3b0f6d5539680eff5a1ef45197c7e542e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 03:24:06 +0000 Subject: [PATCH 06/15] add setup containerd action --- .github/workflows/deploy-DEV-linters.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index c72abe2147d..bcd74291424 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -200,6 +200,9 @@ jobs: uses: docker/setup-qemu-action@v3 if: ${{ ( ( runner.arch != 'X64' || runner.os != 'Linux' ) && matrix.platform == 'linux/amd64' ) || matrix.platform != 'linux/amd64' }} + - + name: Set up containerd + uses: crazy-max/ghaction-setup-containerd@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From 82da117ec9e4396c8feed05132d47d2099a39a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 03:26:43 +0000 Subject: [PATCH 07/15] comment out outputs --- .github/workflows/deploy-DEV-linters.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index bcd74291424..d445c71dfaf 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -225,7 +225,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true - outputs: type=image + #outputs: type=image ##################################### # Run Linter test cases # From faa8b2872b038f0c45c725c38e3d3c07517748a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 04:52:22 +0000 Subject: [PATCH 08/15] Use a local registry service --- .github/workflows/deploy-DEV-linters.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index d445c71dfaf..47098d5a65f 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -38,6 +38,13 @@ jobs: # Set the agent to run on runs-on: ubuntu-latest permissions: read-all + services: + registry: + image: registry:2 + ports: + - 5000:5000 + env: + REGISTRY_PREFIX: localhost:5000 strategy: fail-fast: false max-parallel: 14 @@ -194,7 +201,7 @@ jobs: id: meta with: images: | - ${{ github.repository }}-only-${{ matrix.linter }} + ${{ env.REGISTRY_PREFIX }}/${{ github.repository }}-only-${{ matrix.linter }} - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -217,6 +224,8 @@ jobs: BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} + #load: true + #push: false load: true push: false secrets: | @@ -239,7 +248,7 @@ jobs: TEST_KEYWORDS_TO_USE_UPPER="${{ matrix.linter }}" TEST_KEYWORDS_TO_USE="${TEST_KEYWORDS_TO_USE_UPPER,,}" docker image ls - docker run -e TEST_CASE_RUN=true -e OUTPUT_FORMAT=text -e OUTPUT_FOLDER=${{ github.sha }} -e OUTPUT_DETAIL=detailed -e GITHUB_SHA=${{ github.sha }} -e GITHUB_REPOSITORY=${GITHUB_REPOSITORY} -e GITHUB_BRANCH=${GITHUB_BRANCH} -e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -e TEST_KEYWORDS="${TEST_KEYWORDS_TO_USE}" -e MEGALINTER_VOLUME_ROOT="${GITHUB_WORKSPACE}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v ${GITHUB_WORKSPACE}:/tmp/lint ${{ fromJson(steps.meta.outputs.json).tags[0]}} + docker run -e TEST_CASE_RUN=true -e OUTPUT_FORMAT=text -e OUTPUT_FOLDER=${{ github.sha }} -e OUTPUT_DETAIL=detailed -e GITHUB_SHA=${{ github.sha }} -e GITHUB_REPOSITORY=${GITHUB_REPOSITORY} -e GITHUB_BRANCH=${GITHUB_BRANCH} -e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -e TEST_KEYWORDS="${TEST_KEYWORDS_TO_USE}" -e MEGALINTER_VOLUME_ROOT="${GITHUB_WORKSPACE}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v ${GITHUB_WORKSPACE}:/tmp/lint ${{ env.REGISTRY_PREFIX }}/${{ fromJson(steps.meta.outputs.json).tags[0]}} timeout-minutes: 30 ############################################## @@ -248,7 +257,7 @@ jobs: - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master with: - image-ref: 'docker.io/${{ fromJson(steps.meta.outputs.json).tags[0] }}' + image-ref: '${{ env.REGISTRY_PREFIX }}/${{ fromJson(steps.meta.outputs.json).tags[0] }}' format: 'table' exit-code: '1' ignore-unfixed: true From c84c01c70f66eb1b80992b24aecf68c7765b64b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 04:54:49 +0000 Subject: [PATCH 09/15] Push image to local registry --- .github/workflows/deploy-DEV-linters.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index 47098d5a65f..ef65c5d3ec0 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -226,8 +226,8 @@ jobs: BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} #load: true #push: false - load: true - push: false + #load: true + push: true secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} tags: ${{ steps.meta.outputs.tags }} From 3107c7de58a5a432e7953ce89ed935d8135c57ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 05:01:34 +0000 Subject: [PATCH 10/15] Add host network to docker buildx builder options --- .github/workflows/deploy-DEV-linters.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index ef65c5d3ec0..4ae712417b2 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -207,12 +207,14 @@ jobs: uses: docker/setup-qemu-action@v3 if: ${{ ( ( runner.arch != 'X64' || runner.os != 'Linux' ) && matrix.platform == 'linux/amd64' ) || matrix.platform != 'linux/amd64' }} - - - name: Set up containerd - uses: crazy-max/ghaction-setup-containerd@v3 + #- + # name: Set up containerd + # uses: crazy-max/ghaction-setup-containerd@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + driver-opts: network=host - name: Build Image uses: docker/build-push-action@v5 From 03becd79a04abe915ce54795fab1ef788a1a76b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 05:08:27 +0000 Subject: [PATCH 11/15] Remove duplicated registry prefix --- .github/workflows/deploy-DEV-linters.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index 4ae712417b2..9e0519e558b 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -44,6 +44,7 @@ jobs: ports: - 5000:5000 env: + # If using Docker Hub, trivy would need to have docker.io as prefix REGISTRY_PREFIX: localhost:5000 strategy: fail-fast: false @@ -250,7 +251,7 @@ jobs: TEST_KEYWORDS_TO_USE_UPPER="${{ matrix.linter }}" TEST_KEYWORDS_TO_USE="${TEST_KEYWORDS_TO_USE_UPPER,,}" docker image ls - docker run -e TEST_CASE_RUN=true -e OUTPUT_FORMAT=text -e OUTPUT_FOLDER=${{ github.sha }} -e OUTPUT_DETAIL=detailed -e GITHUB_SHA=${{ github.sha }} -e GITHUB_REPOSITORY=${GITHUB_REPOSITORY} -e GITHUB_BRANCH=${GITHUB_BRANCH} -e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -e TEST_KEYWORDS="${TEST_KEYWORDS_TO_USE}" -e MEGALINTER_VOLUME_ROOT="${GITHUB_WORKSPACE}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v ${GITHUB_WORKSPACE}:/tmp/lint ${{ env.REGISTRY_PREFIX }}/${{ fromJson(steps.meta.outputs.json).tags[0]}} + docker run -e TEST_CASE_RUN=true -e OUTPUT_FORMAT=text -e OUTPUT_FOLDER=${{ github.sha }} -e OUTPUT_DETAIL=detailed -e GITHUB_SHA=${{ github.sha }} -e GITHUB_REPOSITORY=${GITHUB_REPOSITORY} -e GITHUB_BRANCH=${GITHUB_BRANCH} -e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" -e TEST_KEYWORDS="${TEST_KEYWORDS_TO_USE}" -e MEGALINTER_VOLUME_ROOT="${GITHUB_WORKSPACE}" -v "/var/run/docker.sock:/var/run/docker.sock:rw" -v ${GITHUB_WORKSPACE}:/tmp/lint ${{ fromJson(steps.meta.outputs.json).tags[0]}} timeout-minutes: 30 ############################################## @@ -259,7 +260,7 @@ jobs: - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master with: - image-ref: '${{ env.REGISTRY_PREFIX }}/${{ fromJson(steps.meta.outputs.json).tags[0] }}' + image-ref: '${{ fromJson(steps.meta.outputs.json).tags[0] }}' format: 'table' exit-code: '1' ignore-unfixed: true From d6bc8820a2d5af5abac04a8c60f22c2f88a2a0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 05:22:48 +0000 Subject: [PATCH 12/15] Add local registry to deploy-DEV --- .github/workflows/deploy-DEV.yml | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-DEV.yml b/.github/workflows/deploy-DEV.yml index da50d058b99..983503c651f 100644 --- a/.github/workflows/deploy-DEV.yml +++ b/.github/workflows/deploy-DEV.yml @@ -57,6 +57,14 @@ jobs: if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository) && !contains(github.event.head_commit.message, 'skip deploy') # Set max build time for the job timeout-minutes: 120 + services: + registry: + image: registry:2 + ports: + - 5000:5000 + env: + # If using Docker Hub, trivy would need to have docker.io as prefix + REGISTRY_PREFIX: localhost:5000 ################## # Load all steps # ################## @@ -69,13 +77,15 @@ jobs: id: meta with: images: | - ${{ github.repository }} + ${{ env.REGISTRY_PREFIX }}/${{ github.repository }} - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + driver-opts: network=host # Free disk space - name: Free Disk space @@ -100,8 +110,9 @@ jobs: BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} MEGA_LINTER_BASE_IMAGE="oxsecurity/megalinter:beta" - load: true - push: false + #load: true + #push: false + push: true secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} tags: ${{ steps.meta.outputs.tags }} @@ -131,8 +142,9 @@ jobs: BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} - load: true - push: false + #load: true + #push: false + push: true secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} tags: ${{ steps.meta.outputs.tags }} @@ -161,8 +173,9 @@ jobs: BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} - load: true - push: false + #load: true + #push: false + push: true secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} tags: ${{ steps.meta.outputs.tags }} From 7cdf97950d0cf5d02846dbf7cfdf8db96349868b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 06:37:36 +0000 Subject: [PATCH 13/15] Clean commented steps --- .github/workflows/deploy-DEV-linters.yml | 8 -------- .github/workflows/deploy-DEV.yml | 8 +------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index 9e0519e558b..e90cfa1ac4e 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -207,10 +207,6 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v3 if: ${{ ( ( runner.arch != 'X64' || runner.os != 'Linux' ) && matrix.platform == 'linux/amd64' ) || matrix.platform != 'linux/amd64' }} - - #- - # name: Set up containerd - # uses: crazy-max/ghaction-setup-containerd@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -227,9 +223,6 @@ jobs: BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} - #load: true - #push: false - #load: true push: true secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} @@ -237,7 +230,6 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true - #outputs: type=image ##################################### # Run Linter test cases # diff --git a/.github/workflows/deploy-DEV.yml b/.github/workflows/deploy-DEV.yml index 983503c651f..512011768b8 100644 --- a/.github/workflows/deploy-DEV.yml +++ b/.github/workflows/deploy-DEV.yml @@ -110,8 +110,6 @@ jobs: BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} MEGA_LINTER_BASE_IMAGE="oxsecurity/megalinter:beta" - #load: true - #push: false push: true secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} @@ -142,8 +140,6 @@ jobs: BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} - #load: true - #push: false push: true secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} @@ -173,8 +169,6 @@ jobs: BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} BUILD_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} BUILD_REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} - #load: true - #push: false push: true secrets: | GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} @@ -271,7 +265,7 @@ jobs: # - name: Run Trivy vulnerability scanner # uses: aquasecurity/trivy-action@master # with: - # image-ref: "docker.io/${{ fromJson(steps.meta.outputs.json).tags[0]}}" + # image-ref: "${{ fromJson(steps.meta.outputs.json).tags[0]}}" # format: 'table' # exit-code: '1' # ignore-unfixed: true From c2157f3407f0df642fa40b5a401bff99324f793a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 06:45:33 +0000 Subject: [PATCH 14/15] try outputting oci image with estargz --- .github/workflows/deploy-DEV-linters.yml | 1 + .github/workflows/deploy-DEV.yml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index e90cfa1ac4e..008879086d7 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -230,6 +230,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true + output: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true ##################################### # Run Linter test cases # diff --git a/.github/workflows/deploy-DEV.yml b/.github/workflows/deploy-DEV.yml index 512011768b8..a06fd3e5363 100644 --- a/.github/workflows/deploy-DEV.yml +++ b/.github/workflows/deploy-DEV.yml @@ -117,6 +117,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true + output: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true timeout-minutes: 90 ####################################### @@ -147,6 +148,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true + output: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true timeout-minutes: 90 #################################### @@ -176,6 +178,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true + output: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true # Clean docker build cache - name: Clean docker buildx cache From 141dbcca0384482e5f77f1d55c7a17da3018aa4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Wed, 6 Dec 2023 06:50:51 +0000 Subject: [PATCH 15/15] fix typo in outputs --- .github/workflows/deploy-DEV-linters.yml | 2 +- .github/workflows/deploy-DEV.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index 008879086d7..284ebb16b4f 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -230,7 +230,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true - output: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true + outputs: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true ##################################### # Run Linter test cases # diff --git a/.github/workflows/deploy-DEV.yml b/.github/workflows/deploy-DEV.yml index a06fd3e5363..4588bf597ee 100644 --- a/.github/workflows/deploy-DEV.yml +++ b/.github/workflows/deploy-DEV.yml @@ -117,7 +117,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true - output: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true + outputs: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true timeout-minutes: 90 ####################################### @@ -148,7 +148,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true - output: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true + outputs: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true timeout-minutes: 90 #################################### @@ -178,7 +178,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} provenance: true sbom: true - output: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true + outputs: type=registry,oci-mediatypes=true,compression=estargz,force-compression=true # Clean docker build cache - name: Clean docker buildx cache