env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository_owner }}/caddy-l4

name: Build caddy-l4
on:
  workflow_dispatch:

permissions: write-all

jobs:
  build_ee:
    runs-on: ubicloud
    steps:
      - uses: actions/checkout@v4
      - uses: depot/setup-action@v1
      - name: Docker meta
        id: meta-ee-public
        uses: docker/metadata-action@v5
        with:
          images: |
            ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
          tags: |
            type=sha
            type=ref,event=branch
            type=raw,value=latest,enable={{is_default_branch}}

      - name: Login to registry
        uses: docker/login-action@v3
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push publicly
        uses: depot/build-push-action@v1
        with:
          context: ./docker
          file: ./docker/DockerfileCaddyL4
          platforms: linux/amd64,linux/arm64
          push: true
          tags: |
            ${{ steps.meta-ee-public.outputs.tags }}
          labels: |
            ${{ steps.meta-ee-public.outputs.labels }}
