name: Build and Push Docker Image

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build_and_push:
    runs-on: ubuntu-latest

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

      - name: Log in to Gitea Package Registry
        uses: docker/login-action@v3
        with:
          registry: ${{ secrets.SERVER_URL }}
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PACKAGE_TOKEN }}

      - name: Build Docker Image
        run: docker build -t git.pontusmail.org/librecloud/web:latest .

      - name: Push Docker Image
        run: docker push git.pontusmail.org/librecloud/web:latest