name: Docker Image CI/CD

on:
  push:
    branches: ["main"]
    paths:
      - "docker/**"
  pull_request:
    paths:
      - "docker/**"

jobs:
  build_and_push:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v4

      - name: "Login to GitHub Container Registry"
        uses: docker/login-action@v1
        with:
          registry: ghcr.io
          username: ${{github.actor}}
          password: ${{secrets.GITHUB_TOKEN}}

      - name: Build the Docker image
        run: |
          docker build docker/slim --platform linux/amd64,linux/arm64,linux/arm32v6,linux/arm32v7 -t multi-platform --tag ghcr.io/dora-rs/dora-slim:latest
          docker push ghcr.io/dora-rs/dora-slim:latest
