perfect-postcode/.github/workflows/docker-publish.yml
2026-03-15 09:02:20 +00:00

84 lines
2.5 KiB
YAML

name: Build and publish Docker image
on:
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: 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
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.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push screenshot service
uses: docker/build-push-action@v6
with:
context: ./screenshot
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-screenshot:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-screenshot:sha-${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=screenshot
cache-to: type=gha,mode=max,scope=screenshot
- name: Set up uv
uses: astral-sh/setup-uv@v4
- name: Download arcgis data for finder
run: uv run python -m pipeline.download.arcgis --output property-data/arcgis_data.parquet
- name: Build and push finder service
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.finder
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-finder:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-finder:sha-${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=finder
cache-to: type=gha,mode=max,scope=finder