Skip to content

Docker Build

Docker Build #8191

name: Docker Build
on:
pull_request:
push:
branches:
- "[0-9]+.[0-9]+.x"
- 'v[0-9]+'
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
schedule:
- cron: "0 * * * *" # Runs hourly
concurrency:
group: ${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
packages: write
env:
SUPPORTED_PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
DOCKER_IMAGE: "ghcr.io/${{ github.repository_owner }}/compliance"
jobs:
cleanup:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
steps:
- uses: actions/delete-package-versions@v5
with:
package-name: 'compliance'
package-type: 'container'
min-versions-to-keep: 30
delete-only-untagged-versions: 'true'
builder:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE }}
labels: |
maintainer=Ghostwriter
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Packages Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Build and Push ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}
uses: docker/build-push-action@v6
with:
cache-from: type=gha,scope=${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}
cache-to: type=gha,scope=${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }},mode=max
platforms: ${{ env.SUPPORTED_PLATFORMS}}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}