Fix build workflow

Signed-off-by: Tommy <contact@tommytran.io>
This commit is contained in:
Tommy 2024-05-29 11:30:58 -07:00
parent 5d912a76c7
commit c885c640f0
No known key found for this signature in database
GPG key ID: 555C902A34EC968F

View file

@ -18,7 +18,7 @@ env:
jobs:
build:
name: Build, scan & push
name: Build & push new image
runs-on: "ubuntu-latest"
permissions:
contents: read
@ -27,7 +27,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Extract version for tags
run: |
@ -36,16 +36,14 @@ jobs:
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@main
with:
cosign-release: 'v2.0.1'
uses: sigstore/cosign-installer@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
- name: Login to registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
@ -53,7 +51,7 @@ jobs:
- name: Set Docker metadata
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
@ -63,7 +61,7 @@ jobs:
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
@ -74,5 +72,24 @@ jobs:
if: ${{ github.event_name != 'pull_request' }}
run: cosign sign ${TAGS} -y
env:
COSIGN_EXPERIMENTAL: "true"
TAGS: ${{ steps.meta.outputs.tags }}
scan:
name: Scan current image & report results
needs: build
runs-on: "ubuntu-latest"
steps:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'ghcr.io/wonderfall/synapse'
format: 'template'
template: '@/contrib/sarif.tpl'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
vuln-type: "os"
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'