Skip to content

feat: enhance logging setup and add rich output support with figlet #10

feat: enhance logging setup and add rich output support with figlet

feat: enhance logging setup and add rich output support with figlet #10

name: Docker Build and Trivy Scan
on:
push:
branches:
- '**'
workflow_call:
inputs:
DOCKER_PATH_CONTEXT:
required: true
type: string
DOCKER_BUILD_DOCKERFILE:
required: true
type: string
DOCKER_LOAD_BOOL:
required: true
type: boolean
DOCKER_TAGS:
required: true
type: string
jobs:
build-and-scan:
runs-on: ubuntu-latest
env:
DOCKER_PATH_CONTEXT: .
DOCKER_BUILD_DOCKERFILE: Dockerfile
DOCKER_LOAD_BOOL: true
DOCKER_TAGS: sample-python-app:${{ github.sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker Image
id: build-image
uses: docker/build-push-action@v6
with:
context: ${{ inputs.DOCKER_PATH_CONTEXT || env.DOCKER_PATH_CONTEXT }}
file: ${{ inputs.DOCKER_BUILD_DOCKERFILE || env.DOCKER_BUILD_DOCKERFILE }}
load: ${{ inputs.DOCKER_LOAD_BOOL || env.DOCKER_LOAD_BOOL }}
tags: ${{ inputs.DOCKER_TAGS || env.DOCKER_TAGS }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.33.1
with:
image-ref: ${{ inputs.DOCKER_TAGS || env.DOCKER_TAGS }}
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
- name: Login to DockerHub
if: github.event_name == 'workflow_call'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker image to DockerHub
if: github.event_name == 'workflow_call'
uses: docker/build-push-action@v6
with:
context: ${{ inputs.DOCKER_PATH_CONTEXT || env.DOCKER_PATH_CONTEXT }}
file: ${{ inputs.DOCKER_BUILD_DOCKERFILE || env.DOCKER_BUILD_DOCKERFILE }}
push: true
tags: ${{ inputs.DOCKER_TAGS || env.DOCKER_TAGS }}