From 376a4646c571900194d3f05f36383a1aa4e87863 Mon Sep 17 00:00:00 2001 From: danjov Date: Thu, 7 Nov 2024 14:41:56 +0100 Subject: [PATCH] Use env variable for docker image name --- .github/workflows/trivy.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index c412099..7d7625a 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -22,16 +22,20 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Set environment variables + run: | + echo IMAGE_NAME=$REGISTRY/$(echo ${GITHUB_REPOSITORY,,}) >> $GITHUB_ENV + - name: Build image from Dockerfile run: | - docker build --build-arg VERSION=$GITHUB_RUN_NUMBER --build-arg REVISION=${{ github.sha }} -t ghcr.io/$GITHUB_REPOSITORY:${{ github.sha }} . + docker build --build-arg VERSION=$GITHUB_RUN_NUMBER --build-arg REVISION=${{ github.sha }} -t ${{ env.IMAGE_NAME }}:${{ github.sha }} . - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe env: ACTIONS_RUNTIME_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Addresses https://github.com/aquasecurity/trivy-action/issues/389 with: - image-ref: 'ghcr.io/geowerkstatt/interlis-check-service:${{ github.sha }}' + image-ref: '${{ env.IMAGE_NAME }}:${{ github.sha }}' format: 'template' template: '@/contrib/sarif.tpl' output: 'trivy-results.sarif'