name: PR Docker Build on: pull_request: types: [opened, synchronize, reopened] permissions: contents: read packages: write pull-requests: write jobs: docker: name: Build PR Docker Image runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata id: meta uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository }} tags: | # PR-specific tag for testing type=raw,value=pr-${{ github.event.number }}-${{ github.sha }} type=raw,value=pr-${{ github.event.number }} - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - name: Comment on PR with Docker info uses: actions/github-script@v7 with: script: | const prNumber = context.payload.pull_request.number; const sha = context.sha.substring(0, 7); const repo = context.repo.repo; const owner = context.repo.owner; const comment = `🐳 **Docker Image Built Successfully** This PR has been built and pushed as a Docker image for testing: **Available Tags:** - \`ghcr.io/${owner}/${repo}:pr-${prNumber}-${context.sha}\` - \`ghcr.io/${owner}/${repo}:pr-${prNumber}\` (latest for this PR) **Test the changes:** \`\`\`bash docker pull ghcr.io/${owner}/${repo}:pr-${prNumber} \`\`\` **Claude Desktop configuration:** \`\`\`json { "mcpServers": { "zen-mcp-server": { "command": "docker", "args": [ "run", "--rm", "-i", "-e", "GEMINI_API_KEY", "ghcr.io/${owner}/${repo}:pr-${prNumber}" ], "env": { "GEMINI_API_KEY": "your-api-key-here" } } } } \`\`\` The image will be updated automatically when you push new commits to this PR.`; github.rest.issues.createComment({ issue_number: prNumber, owner: owner, repo: repo, body: comment }); - name: Create deployment summary run: | echo "## 🐳 PR Docker Build Complete" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "**PR**: #${{ github.event.number }}" >> $GITHUB_STEP_SUMMARY echo "**Commit**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY echo "**Images built:**" >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY