Skip to content

Bump docker/metadata-action from 5.3.0 to 5.4.0 #178

Bump docker/metadata-action from 5.3.0 to 5.4.0

Bump docker/metadata-action from 5.3.0 to 5.4.0 #178

# This workflow will build and push a signed Docker image
name: Build and sign image
on:
pull_request:
types:
- closed
branches:
- "main"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build_and_sign_image:
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install cosign
uses: sigstore/cosign-installer@9614fae9e5c5eddabb09f90a270fcb487c9f7149 #v3.0.2
with:
cosign-release: 'v1.13.1'
- name: Log into registry ${{ env.REGISTRY }} for ${{ github.actor }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9dc751fe249ad99385a2583ee0d084c400eee04e
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build Docker Image
id: docker-build-and-push
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{github.run_number}}
- name: Sign the published Docker images
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: cosign sign "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.docker-build-and-push.outputs.digest }}"
# NOTE: This runs statically against the latest tag in Docker Hub which was not produced by this workflow
# This should be updated once this workflow is fully implemented
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@91713af97dc80187565512baba96e4364e983601 # 0.16.0
continue-on-error: true
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
format: 'sarif'
output: 'trivy-results-${{ inputs.image }}.sarif'
ignore-unfixed: 'true'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@b374143c1149a9115d881581d29b8390bbcbb59c # v2.2.11
continue-on-error: true
with:
sarif_file: 'trivy-results-${{ inputs.image }}.sarif'
sha: ${{ github.sha }}
ref: ${{ github.ref }}