Skip to content

Docker Images CI

Docker Images CI #402

Workflow file for this run

---
name: Docker Images CI
on:
push:
pull_request:
schedule:
- cron: "0 0 * * 1"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
permissions:
actions: read
contents: read
packages: write
security-events: write
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hadolint/[email protected]
with:
dockerfile: "*Dockerfile"
recursive: true
failure-threshold: error
build:
name: Build - ${{ matrix.os }}
runs-on: ubuntu-latest
needs: ["lint"]
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
- ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,enable=true,value=${{ matrix.os }}
labels: |
org.opencontainers.image.version=${{ matrix.os }}
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
- name: Build and push Docker image
id: push
uses: docker/[email protected]
with:
context: ./
file: ${{ matrix.os }}.Dockerfile
platforms: linux/amd64,linux/arm64
provenance: false
pull: true
push: ${{ github.ref == 'refs/heads/main' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
- name: Run Snyk to check Docker image for vulnerabilities
continue-on-error: true
uses: snyk/actions/docker@master
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os }}
args: --file=${{ matrix.os }}.Dockerfile --severity-threshold=high --sarif-file-output=snyk.sarif
sarif: true
- name: Post process snyk sarif file
run: |
sed -i 's/"security-severity": "null"/"security-severity": "0"/g' snyk.sarif
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: snyk.sarif
delete-package-versions:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: ["build"]
steps:
- uses: actions/[email protected]
with:
package-name: 'docker-systemd'
package-type: 'container'
min-versions-to-keep: 9
delete-only-untagged-versions: 'true'