Skip to content

Build Docker Image

Build Docker Image #15

Workflow file for this run

name: Build Docker Image
on:
push:
paths:
- "mnist/**"
workflow_dispatch:
jobs:
build:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GHCR
id: login
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate date based tag
id: tag
run: echo "tag=$(date +'%Y%m%d%H%M')" > $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ./mnist
push: true
tags: ghcr.io/bahe-msft/gpu-image/mnist-gpu:${{ steps.tag.outputs.tag }}
- name: Generate Trivy Report
uses: aquasecurity/[email protected]
with:
scan-type: "image"
format: "json"
output: "report.json"
ignore-unfixed: true
vuln-type: "os"
image-ref: ghcr.io/bahe-msft/gpu-image/mnist-gpu:${{ steps.tag.outputs.tag }}
- name: Run Copa action
id: copa
uses: project-copacetic/copa-action@main
with:
image: ghcr.io/bahe-msft/gpu-image/mnist-gpu:${{ steps.tag.outputs.tag }}
image-report: "report.json"
patched-tag: "${{ steps.tag.outputs.tag }}-patched"
timeout: "5m" # optional, default is 5m
output: vex.json # optional
format: "openvex" # optional, default is openvex
# copa-version: "0.6.0" # optional, default is latest
# buildkit-version: "v0.12.4" # optional, default is latest
# custom-socket: "/var/run/buildkit/buildkitd.sock" # optional, used for custom socket address
- name: Scan patched image with Trivy
uses: aquasecurity/[email protected]
with:
scan-type: "image"
format: "json"
output: "patched-report.json"
ignore-unfixed: true
image-ref: ${{ steps.copa.outputs.patched-image }}
- name: Push patched image
if: steps.login.conclusion == 'success'
run: |
docker images
docker push ${{ steps.copa.outputs.patched-image }}