name: Build Docker Image
on:
push:
branches: [ main ]
paths:
- 'main.py'
- 'Dockerfile'
- '.env'
- '.env.example'
- 'pyproject.toml'
- 'uv.lock'
- 'README.md'
- 'QUICKSTART.md'
- 'src/**'
- 'tests/**'
pull_request:
branches: [ main ]
paths:
- 'main.py'
- 'Dockerfile'
- '.env'
- '.env.example'
- 'pyproject.toml'
- 'uv.lock'
- 'README.md'
- 'QUICKSTART.md'
- 'src/**'
- 'tests/**'
permissions:
id-token: write
contents: read
env:
REGISTRY_NAME: kunhoregistry
IMAGE_NAME: email-send-mcp
ACR_RESOURCE_GROUP: fastcmp-rg
jobs:
build-and-push:
runs-on: ubuntu-latest
outputs:
image-tag: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Azure Login via OIDC
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Log in to ACR
run: az acr login --name ${{ env.REGISTRY_NAME }}.azurecr.io
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max