Skip to content

Commit

Permalink
ci: fix scan job (#34)
Browse files Browse the repository at this point in the history
* ci: fix `scan` job

* ci: remove duplicate `latest` push

* ci: trigger CI

* ci: upload vulnerabilities to GitHub Security

* ci: add missing permission

* ci: add missing permissions

* ci: revert tests
  • Loading branch information
JoshuaLicense authored Jul 2, 2024
1 parent 958a603 commit d948eec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@ jobs:
contents: read
id-token: write
packages: write
actions: read
security-events: write
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ jobs:
permissions:
contents: read
id-token: write
actions: read
security-events: write
17 changes: 14 additions & 3 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
flavor: latest=true
images: |
${{ env.REGISTRY }}/${{ inputs.repository }}
${{ env.REGISTRY_MIRROR }}/dvsa/dvsa-docker-images/${{ inputs.repository }}
tags: |
type=raw,value=latest
type=semver,enable=${{ inputs.is-release || inputs.is-schedule-release }},pattern={{major}}.{{minor}},value=${{ inputs.image-version }}
type=semver,enable=${{ inputs.is-release || inputs.is-schedule-release }},pattern={{major}},value=${{ inputs.image-version }}
type=semver,enable=${{ inputs.is-release }},pattern={{version}},value=${{ inputs.image-version }}
Expand All @@ -85,10 +85,10 @@ jobs:
id: mutable-meta
uses: docker/metadata-action@v5
with:
flavor: latest=true
# Only required for ECR (the main registry) as the mirror registry (GHCR) doesn't support tag immutability.
images: ${{ env.REGISTRY }}/${{ inputs.repository }}
tags: |
type=raw,value=latest
type=semver,enable=${{ inputs.is-release || inputs.is-schedule-release }},pattern={{major}}.{{minor}},value=${{ inputs.image-version }}
type=semver,enable=${{ inputs.is-release || inputs.is-schedule-release }},pattern={{major}},value=${{ inputs.image-version }}
Expand Down Expand Up @@ -153,6 +153,10 @@ jobs:
with:
ref: ${{ inputs.ref || null }}
sparse-checkout: ${{ inputs.dockerfile-directory }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
id: build-and-push
uses: docker/build-push-action@v5
Expand All @@ -162,8 +166,15 @@ jobs:
load: true
tags: image-scan:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Scan
uses: aquasecurity/trivy-action@0.23.0
with:
image-ref: ${{ steps.build-and-push.outputs.imageid }}
# format: 'sarif'
# output: 'trivy-results.sarif'

# - name: Upload Trivy scan results to GitHub Code Scanning
# uses: github/codeql-action/upload-sarif@v3
# with:
# sarif_file: 'trivy-results.sarif'

0 comments on commit d948eec

Please sign in to comment.