name: Build and Publish Docker Image

on:
  push:
    branches:
      - master

env:
  REGISTRY: 192.168.10.174:3000
  IMAGE_NAME: ${{ gitea.repository }}

jobs:
  build-and-push-image:
    runs-on: ubuntu-latest

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

      # Simple login directly with docker login
      - name: Log in to the Container registry
        run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login ${{ env.REGISTRY }} -u "${{ gitea.actor }}" --password-stdin

      # Build standard using docker CLI
      - name: Build Docker image
        run: docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest .

      # Push directly using docker push
      - name: Push Docker image
        run: docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
