name: Build Devpod

on:
  push:
    branches: [main]
    paths:
      - Dockerfile.devpod
      - entrypoint-devpod.sh
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      REGISTRY: registry.digitalocean.com/lunarfront
      DOCKER_HOST: tcp://localhost:2375
      VERSION: devpod-0.1.${{ github.run_number }}

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

      - name: Login to DOCR
        run: echo "${{ secrets.DOCR_TOKEN }}" | docker login registry.digitalocean.com -u token --password-stdin

      - name: Build and push devpod
        run: |
          docker build \
            -t $REGISTRY/manager:$VERSION \
            -t $REGISTRY/manager:devpod-latest \
            -f Dockerfile.devpod .
          docker push $REGISTRY/manager:$VERSION
          docker push $REGISTRY/manager:devpod-latest

