name: Publish cdx Kubernetes image

on:
  push:
    branches: [main]
    paths:
      - modules/sandbox/image/**
      - .github/workflows/cdx-kubernetes-image.yml
  workflow_dispatch:

permissions:
  contents: read
  packages: write

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
      - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c
      - id: build
        uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a
        with:
          context: modules/sandbox/image
          file: modules/sandbox/image/Containerfile
          platforms: linux/amd64
          push: true
          tags: |
            ghcr.io/alexcodeplace/overdeck-agent-sandbox:cdx-${{ github.sha }}
            ghcr.io/alexcodeplace/overdeck-agent-sandbox:cdx-latest
      - run: echo '### `${{ steps.build.outputs.digest }}`' >> "$GITHUB_STEP_SUMMARY"
