name: Build And Push Container

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build-and-push:
    runs-on: docker-build
    env:
      REGISTRY: git.mp-mueller.de
      IMAGE_NAME: git.mp-mueller.de/magges/aoostar-rs
    steps:
      - uses: https://github.com/actions/checkout@v4
      - name: Install Docker CLI
        run: |
          apt-get update
          apt-get install -y docker.io
      - name: Log in to Gitea Registry
        run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login $REGISTRY -u "${{ secrets.REGISTRY_USER }}" --password-stdin
      - name: Build image
        run: docker build -f container/Dockerfile -t $IMAGE_NAME:latest -t $IMAGE_NAME:${{ gitea.sha }} .
      - name: Push image
        run: |
          docker push $IMAGE_NAME:latest
          docker push $IMAGE_NAME:${{ gitea.sha }}
