name: Development Build

on:
  push:
    branches:
      - development

jobs:
  build:
    runs-on: ubuntu-latest

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

    - name: Setup .NET 8 SDK
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: '8.0.x'

    - name: Restore dependencies
      run: dotnet restore

    - name: Build
      run: dotnet build --configuration Release --no-restore

    - name: Test (optional)
      run: dotnet test --no-build --verbosity normal

    - name: Publish
      run: dotnet publish -c Release -o out

    - name: Build Docker Image
      run: docker build -t watcher:development .

    - name: Login to Gitea Container Registry
      run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login git.triggermeelmo.com -u ${{ secrets.DOCKER_USERNAME }} --password-stdin

    - name: Tag image
      run: docker tag watcher:development git.triggermeelmo.com/daniel-hbn/watcher/watcher:development

    - name: Push image
      run: docker push git.triggermeelmo.com/daniel-hbn/watcher/watcher:development