Files
rfid-database/.github/workflows/docker.yml
T
Nick TrochalakisandCursor Agent 443dba5bba Publish Docker image to GHCR on each main build (#8)
Add a Docker workflow that builds on PRs and pushes to
ghcr.io/chewbaccalakis/rfid-database on main (latest + sha) and v* tags.
Drop the redundant docker-build job from CI.

Co-authored-by: Cursor Agent <[email protected]>
2026-08-24 04:10:58 +00:00

61 lines
1.6 KiB
YAML

name: Docker
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
env:
REGISTRY: ghcr.io
# GHCR requires lowercase image names
IMAGE_NAME: ghcr.io/chewbaccalakis/rfid-database
jobs:
build-and-push:
name: build-and-push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=sha-,format=short
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max