name: Build and publish docker image snapshot
run-name: ${{ gitea.actor }} runs ci pipeline
on: [ push ]

jobs:
  build-and-publish:
    runs-on: ubuntu-latest
    if: gitea.ref == 'refs/heads/master'
    steps:
      - name: Check out repository code
        uses: actions/checkout@v4

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Login to Gitea Container Registry
        uses: docker/login-action@v3
        with:
          registry: gitea.forstenlechner.dev
          username: stefan
          password: ${{ secrets.ACTION_TOKEN }}
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ secrets.GHCR_USER }}
          password: ${{ secrets.GHCR_TOKEN }}

      - name: Build and push Docker image
        uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          tags: |
            gitea.forstenlechner.dev/stefan/simple-picture-gallery:latest
            ghcr.io/t-h-e/simple-picture-gallery:latest
