name: Publish Docker image
on:
push:
branches:
- main
- master
tags:
- v*
permissions: write-all
jobs:
build_images:
name: Build and Push Images
runs-on: ubuntu-latest
strategy:
matrix:
target:
- name: Build and Push Images (Latest / Release)
target_step: prod
tag: ghcr.io/${{ github.repository }}
steps:
- name: Disable SSL Verify
run: git config --global http.sslVerify false
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to the Container registry
uses: docker/login-action@v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup docker context for buildx
run: |
docker context create builders || docker context use builders
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.target.tag }}
tags: |
latest
type=ref,event=tag
- name: Extract Image Name
id: extracted_name
run: |
IMAGE_NAME=$(echo "${{ steps.meta.outputs.tags }}" | head -n1 | cut -d':' -f1)
echo "name=$IMAGE_NAME" >> $GITHUB_OUTPUT
- name: ${{ matrix.target.name }}
uses: docker/build-push-action@v6
with:
push: true
context: .
file: ./docker/Dockerfile
target: ${{ matrix.target.target_step }}
tags: |
${{ steps.meta.outputs.tags }}
sbom: false
provenance: false
cache-from: type=registry,ref=${{ steps.extracted_name.outputs.name }}:buildcache
cache-to: type=registry,ref=${{ steps.extracted_name.outputs.name }}:buildcache,image-manifest=true,oci-mediatypes=true,mode=max