name: Build Docker Image
on:
  push:
    branches:
     - "**"
    tags:
      - "v*.*.*"
jobs:
  build-image:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: Docker Metadata
      id: metadata
      uses: docker/metadata-action@v5
      with:
        images: git.thornbush.dev/rose/fixbluesky
        tags: |
          type=ref,event=branch
          type=sha,prefix=
          type=edge,branch=devel
          type=semver,pattern={{version}}
          type=semver,pattern={{major}}.{{minor}}
          type=semver,pattern={{major}}
    - name: Docker Buildx
      uses: https://code.forgejo.org/docker/setup-buildx-action@v3
    - name: Login to Docker Registry
      if: github.event_name != 'pull_request'
      uses: https://code.forgejo.org/docker/login-action@v3
      with:
        registry: git.thornbush.dev
        username: ${{github.actor}}
        password: ${{secrets.OAUTH_TOKEN}}
    - name: Build Image
      uses: https://code.forgejo.org/docker/build-push-action@v6
      with:
        context: .
        file: ./Dockerfile
        push: ${{ github.event_name != 'pull_request' }}
        tags: ${{ steps.metadata.outputs.tags }}
        labels: ${{ steps.metadata.outputs.labels }}
