name: Build and Push to Harbor

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  build-and-push:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

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

      - name: Login to Harbor
        uses: docker/login-action@v3
        with:
          registry: images.caffeinetux.com
          username: admin
          password: ${{ secrets.HARBOR_PASSWORD }}

      - name: Build and push
        uses: docker/build-push-action@v5
        with:
          context: ./htlm
          platforms: linux/amd64,linux/arm64,linux/arm/v7
          push: true
          tags: |
            images.caffeinetux.com/apps/neon-vortex:latest
            images.caffeinetux.com/apps/neon-vortex:${{ github.sha }}
          cache-from: type=registry,ref=images.caffeinetux.com/apps/neon-vortex:buildcache
          cache-to: type=registry,ref=images.caffeinetux.com/apps/neon-vortex:buildcache,mode=max
