Skip to content

CI (Auto-tag + Push Docker) #21

CI (Auto-tag + Push Docker)

CI (Auto-tag + Push Docker) #21

Workflow file for this run

# .github/workflows/ci.yml
name: CI (Build & Push Docker)
on:
push:
branches: [ "main" ]
tags: [ "v*.*.*" ]
workflow_dispatch: {}
env:
REGISTRY: docker.io
IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/gabs-redis-langcache
DOCKERFILE: ./Dockerfile
permissions:
contents: read # no write permissions needed
jobs:
build-and-push:
name: Build & Push multi-arch image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Checkout
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: Log in to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Sanitize Docker context env
run: echo "DOCKER_CONTEXT=" >> $GITHUB_ENV
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.source=${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Build & Push (linux/amd64 + linux/arm64)
uses: docker/build-push-action@v6
with:
context: .
file: ${{ env.DOCKERFILE }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false