name: Build and publish a Docker image

on:
  push:
    branches:
      - main

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  build-and-push-image:
    runs-on: ubuntu-latest
    if: github.repository == 'MultiMote/niimblue'

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

      - name: Log in to the Container registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ secrets.GH_PACKAGES_USERNAME }}
          password: ${{ secrets.GH_PACKAGES_TOKEN }}

      - name: Build and push Docker image
        id: push
        uses: docker/build-push-action@v6
        with:
          context: .
          push: true
          tags: ghcr.io/multimote/niimblue:latest,ghcr.io/multimote/niimblue:gh-${{github.sha}}
