name: Build and Push Astro Image

on:
  push:
    branches: [ "master" ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
        with:
          driver-opts: network=host
          buildkitd-flags: '--allow-insecure-entitlement network.host'
      
      - name: Login to Private Registry
        uses: docker/login-action@v3
        with:
          registry: docker.illegalesachen.download
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Build and Push
        uses: docker/build-push-action@v6
        with:
          context: .
          push: true
          network: host
          allow: network.host
          tags: |
            docker.illegalesachen.download/repository/astro-homepage:latest
            docker.illegalesachen.download/repository/astro-homepage:${{ github.sha }}
