name: Publish Factory Kubernetes image

on:
  push:
    branches: [main]
    paths:
      - modules/harness/factory/**
      - .github/workflows/factory-kubernetes-image.yml

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/harness/factory
          file: modules/harness/factory/kubernetes/Containerfile
          push: true
          tags: |
            ghcr.io/alexcodeplace/overdeck-agent-sandbox:factory-${{ github.sha }}
            ghcr.io/alexcodeplace/overdeck-agent-sandbox:factory-latest
      - run: echo '### `${{ steps.build.outputs.digest }}`' >> "$GITHUB_STEP_SUMMARY"
