Skip to content

Docker Image

Docker Image #1196

Workflow file for this run

name: Docker Image
on:
schedule:
- cron: "0 10 * * *" # everyday at 10am
pull_request:
branches: ["latest"]
push:
branches: ["latest"]
tags: ["v*.*.*"]
env:
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7,linux/s390x,linux/ppc64le
jobs:
main:
runs-on: ubuntu-22.04
timeout-minutes: 20
permissions:
contents: read
packages: write
pull-requests: write
security-events: write
id-token: write
attestations: write
steps:
- name: Check out the repo
uses: actions/checkout@v6
with:
ref: ${{ github.head_ref || github.ref }}
- name: Hadolint
uses: hadolint/hadolint-action@v3.3.0
with:
dockerfile: ./Dockerfile
config: .github/hadolint.yaml
- name: Set imageName based on the repository name
id: step_one
run: |
imageName="${GITHUB_REPOSITORY/docker-/}"
echo $imageName
echo "imageName=$imageName" >> $GITHUB_ENV
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.imageName }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build for PR
id: docker_build_pr
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: false
pull: true
load: true
tags: |
${{ steps.docker_meta.outputs.tags }}
${{ env.imageName }}:pr-${{ github.event.number }}
labels: ${{ steps.docker_meta.outputs.labels }}
- name: Build and push
id: docker_build
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: ${{ env.platforms }}
push: true
pull: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
attests: |
type=sbom
type=provenance,mode=max
- name: Container Structure Tests
if: ${{ github.event_name == 'pull_request' }}
uses: plexsystems/container-structure-test-action@v0.3.0
with:
image: ${{ env.imageName }}:pr-${{ github.event.number }}
config: .github/cst.yaml
- name: Cosign install
if: ${{ github.event_name != 'pull_request' }}
uses: sigstore/cosign-installer@v3
- name: Sign image
if: ${{ github.event_name != 'pull_request' }}
env:
COSIGN_EXPERIMENTAL: "true"
run: |
cosign sign --yes ${{ env.imageName }}@${{ steps.docker_build.outputs.digest }}
- name: Docker Scout
id: docker-scout-cves
if: ${{ github.event_name != 'pull_request' }}
uses: docker/scout-action@v1
with:
command: cves
organization: beevelop
image: ${{ env.imageName }}:latest
to-latest: true
github-token: ${{ secrets.GITHUB_TOKEN }}
sarif-file: sarif.output.json
- name: Upload SARIF result
id: upload-sarif
if: ${{ github.event_name != 'pull_request' }}
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: sarif.output.json
- name: Compare to deployed image
id: docker-scout-compare
if: ${{ github.event_name == 'pull_request' }}
uses: docker/scout-action@v1
with:
command: compare
organization: beevelop
image: ${{ env.imageName }}:pr-${{ github.event.number }}
only-severities: critical,high
platform: "linux/amd64"
exit-on: vulnerability
summary: true