fix(ci): skip PR-comment step on fork PRs (read-only token reds passi… #107
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Publish - Latest | |
| on: | |
| push: | |
| branches: [master] | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| - 'v0/**' | |
| - '.github/workflows/continuous-benchmark.yaml' | |
| - '.github/workflows/manual-benchmark.yaml' | |
| env: | |
| REGISTRY: docker.io | |
| IMAGE_NAME: redis/vector-db-benchmark | |
| jobs: | |
| docker-publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Check Docker Hub credentials | |
| id: check | |
| run: | | |
| if [[ -z "${{ secrets.DOCKER_USERNAME }}" || -z "${{ secrets.DOCKER_PASSWORD }}" ]]; then | |
| # Publishing is optional infrastructure (e.g. before the Docker Hub | |
| # secrets are configured on a fork/new org). Skip it cleanly instead | |
| # of failing the whole push — a perpetually-red master hides real | |
| # regressions. CI + Validate still gate correctness. | |
| echo "Docker Hub credentials not configured — SKIPPING publish." | |
| echo "Set DOCKER_USERNAME and DOCKER_PASSWORD repo secrets to enable it." | |
| echo "has_creds=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Docker Hub credentials are configured" | |
| echo "has_creds=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Log in to Docker Hub | |
| if: steps.check.outputs.has_creds == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Extract metadata for Docker | |
| if: steps.check.outputs.has_creds == 'true' | |
| id: docker_meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=latest | |
| - name: Build and push Docker image | |
| if: steps.check.outputs.has_creds == 'true' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.docker_meta.outputs.tags }} | |
| labels: ${{ steps.docker_meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Update Docker Hub description | |
| if: steps.check.outputs.has_creds == 'true' | |
| uses: peter-evans/dockerhub-description@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| repository: redis/vector-db-benchmark | |
| readme-filepath: ./DOCKER_README.md | |
| - name: Generate summary | |
| run: | | |
| if [[ "${{ steps.check.outputs.has_creds }}" != "true" ]]; then | |
| echo "## Docker Publish skipped" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Docker Hub credentials (\`DOCKER_USERNAME\` / \`DOCKER_PASSWORD\`) are not configured on this repository, so the image was **not** published. Set those repo secrets to enable publishing." >> $GITHUB_STEP_SUMMARY | |
| exit 0 | |
| fi | |
| echo "## Docker Image Published" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Repository:** \`${{ env.IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tags:**" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "${{ steps.docker_meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Usage:**" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY | |
| echo "docker run --rm ${{ env.IMAGE_NAME }}:latest --help" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "[View on Docker Hub](https://hub.docker.com/r/redis/vector-db-benchmark)" >> $GITHUB_STEP_SUMMARY |