name: Pub Docker Img on: push: branches: [main] tags: ["v*"] paths: - "Dockerfile" - ".dockerignore" - "Cargo.toml" - "Cargo.lock" - "rust-toolchain.toml" - "src/**" - "crates/**" - "benches/**" - "firmware/**" - "dev/config.template.toml" - ".github/workflows/pub-docker-img.yml" pull_request: branches: [main] paths: - "Dockerfile" - ".dockerignore" - "Cargo.toml" - "Cargo.lock" - "rust-toolchain.toml" - "src/**" - "crates/**" - "benches/**" - "firmware/**" - "dev/config.template.toml" - ".github/workflows/pub-docker-img.yml" workflow_dispatch: concurrency: group: docker-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} jobs: pr-smoke: name: PR Docker Smoke if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) runs-on: blacksmith-2vcpu-ubuntu-2404 timeout-minutes: 25 permissions: contents: read steps: - name: Checkout repository uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 - name: Setup Blacksmith Builder uses: useblacksmith/setup-docker-builder@ef12d5b165b596e3aa44ea8198d8fde563eab402 # v1 - name: Extract metadata (tags, labels) if: github.event_name == 'pull_request' id: meta uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=pr - name: Build smoke image uses: useblacksmith/build-push-action@30c71162f16ea2c27c3e21523255d209b8b538c1 # v2 with: context: . push: false load: true provenance: false sbom: false tags: zeroclaw-pr-smoke:latest labels: ${{ steps.meta.outputs.labels || '' }} platforms: linux/amd64 - name: Verify image run: docker run --rm zeroclaw-pr-smoke:latest --version publish: name: Build and Push Docker Image if: (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')))) && github.repository == 'zeroclaw-labs/zeroclaw' runs-on: blacksmith-2vcpu-ubuntu-2404 timeout-minutes: 25 permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 - name: Setup Blacksmith Builder uses: useblacksmith/setup-docker-builder@ef12d5b165b596e3aa44ea8198d8fde563eab402 # v1 - name: Log in to Container Registry uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Compute tags id: meta shell: bash run: | set -euo pipefail IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" SHA_TAG="${IMAGE}:sha-${GITHUB_SHA::12}" if [[ "${GITHUB_REF}" == refs/tags/* ]]; then TAG_NAME="${GITHUB_REF#refs/tags/}" TAGS="${IMAGE}:${TAG_NAME},${SHA_TAG}" elif [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then TAGS="${IMAGE}:latest,${SHA_TAG}" else BRANCH_NAME="${GITHUB_REF#refs/heads/}" BRANCH_NAME="${BRANCH_NAME//\//-}" TAGS="${IMAGE}:${BRANCH_NAME},${SHA_TAG}" fi echo "tags=${TAGS}" >> "$GITHUB_OUTPUT" - name: Build and push Docker image uses: useblacksmith/build-push-action@30c71162f16ea2c27c3e21523255d209b8b538c1 # v2 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} platforms: ${{ startsWith(github.ref, 'refs/tags/v') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}