Skip to content

Skip building images on PRs from external users (forks) - #1249

Merged
aantn merged 4 commits into
masterfrom
claude/fix-github-actions-permissions-eK8xz
Dec 29, 2025
Merged

aantn merged 4 commits into
masterfrom
claude/fix-github-actions-permissions-eK8xz

Conversation

@aantn

@aantn aantn commented Dec 28, 2025 •

Copy link
Copy Markdown
Collaborator

It wont succeed anyway

Summary by CodeRabbit

  • Chores
    • CI now detects forked PRs and runs a build-only path for them (no registry auth, Cloud SDK setup, or image push); non-fork PRs continue to build and push multi-platform images (linux/amd64, linux/arm64) with registry tagging.
    • Final comments and image location notifications are posted only for non-fork PRs; duration reporting retained for all runs.
    • Old-style PR comments are cleaned up during workflow start and final phases.

✏️ Tip: You can customize this high-level summary in your review settings.

@aantn
aantn requested a review from arikalon1 December 28, 2025 06:57
@CLAassistant

CLAassistant commented Dec 28, 2025 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Dec 28, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Detects fork PRs in the Docker dev images GitHub Actions workflow and branches execution: fork PRs run a build-only path (no registry auth or push, limited platforms) and skip final PR comments; non-fork PRs perform authenticated multi-platform build-and-push and post final PR messages. Start time captured for duration reporting; old-style PR comments cleaned up at start.

Changes

Cohort / File(s) Summary
Docker Dev Images Workflow
.github/workflows/docker-dev-images.yaml
Added fork_check that sets is_fork; gated registry auth, gcloud/setup, and push steps to run only when is_fork != 'true'. Introduced fork-only build path (push: false, limited platforms). Non-fork path builds & pushes multi-arch images (linux/amd64, linux/arm64). Gate final PR comment posting for non-forks and clean up old-style PR comments during started phase. Adjusted start-time capture name for duration reporting.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant GH as GitHub Actions
    participant ForkCheck as fork_check
    participant Buildx as Docker Buildx
    participant Registry as Container Registry / gcloud
    participant PR as PR comment service

    GH->>ForkCheck: run fork_check -> set is_fork
    alt is_fork == 'true' (fork PR)
        GH->>Buildx: Build image (push: false, limited platforms)
        Buildx-->>GH: build result
        note right of GH `#f8f0e6`: Skip registry auth, gcloud setup, push\nSkip final PR comment
    else is_fork != 'true' (non-fork PR)
        GH->>Registry: Authenticate (gcloud / docker login)
        Registry-->>GH: auth token
        GH->>Buildx: Build & Push multi-platform image (linux/amd64, linux/arm64)
        Buildx-->>Registry: push image & tags
        Registry-->>GH: image URLs
        GH->>PR: Post final image-ready comment (includes duration)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • arikalon1
  • moshemorad

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: skipping Docker image builds for pull requests from forks (external users).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93f5b743378b1e1a79540469662ebbdcea3b311e and 80e8496.

📒 Files selected for processing (1)
  • .github/workflows/docker-dev-images.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: build
  • GitHub Check: llm_evals
🔇 Additional comments (7)
.github/workflows/docker-dev-images.yaml (7)

43-43: Correct gating for non-fork PR comments.

The condition properly prevents fork PRs from triggering PR comments while ensuring non-fork PRs proceed with the build notification.


63-69: Old comment cleanup correctly placed in initial step.

The cleanup of old-style comments has been properly consolidated into the initial "Comment build started" step, addressing the duplication issue flagged in the previous review.


142-157: Registry authentication properly gated for non-fork PRs.

All authentication steps (Google auth, gcloud CLI, Docker registry config) are correctly conditional on non-fork PRs, preventing unnecessary authentication failures for external contributors.


162-173: Fork PR build path correctly implements build-only validation.

The dedicated fork PR build step appropriately:

  • Skips pushing (no registry access needed)
  • Uses single platform to reduce build time
  • Validates that the Dockerfile builds successfully

This aligns well with the PR objective of handling fork PRs gracefully.


174-186: Non-fork PR build and push correctly configured.

The build step properly handles non-fork PRs with multi-platform builds and appropriate registry tagging. The gating ensures fork PRs skip this step.


187-193: Image location printing appropriately gated.

The print step correctly runs only for non-fork PRs that successfully pushed images.


194-290: Final PR comment logic correctly handles both success and failure cases.

The step appropriately:

  • Uses always() to run regardless of build outcome
  • Gates on non-fork PRs to skip for external contributors
  • Calculates and displays build duration
  • Provides comprehensive image details and usage instructions on success
  • Links to build logs on failure

The implementation correctly uses the start time captured at line 38-40 for accurate duration reporting.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Dec 28, 2025 •

Copy link
Copy Markdown
Contributor

✅ Docker image ready for 3522276 (built in 15m 9s)

Use this tag to pull the image for testing.

📋 Copy commands

⚠️ Temporary images are deleted after 30 days. Copy to a permanent registry before using them:

gcloud auth configure-docker us-central1-docker.pkg.dev
docker pull us-central1-docker.pkg.dev/robusta-development/temporary-builds/holmes:3522276
docker tag us-central1-docker.pkg.dev/robusta-development/temporary-builds/holmes:3522276 me-west1-docker.pkg.dev/robusta-development/development/holmes-dev:3522276
docker push me-west1-docker.pkg.dev/robusta-development/development/holmes-dev:3522276

Patch Helm values in one line (choose the chart you use):

HolmesGPT chart:

helm upgrade --install holmesgpt ./helm/holmes \
  --set registry=me-west1-docker.pkg.dev/robusta-development/development \
  --set image=holmes-dev:3522276

Robusta wrapper chart:

helm upgrade --install robusta robusta/robusta \
  --reuse-values \
  --set holmes.registry=me-west1-docker.pkg.dev/robusta-development/development \
  --set holmes.image=holmes-dev:3522276

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
.github/workflows/docker-dev-images.yaml (2)

42-133: Consider adding minimal feedback for fork PR contributors.

Fork PR contributors receive no comments about build status since this step is skipped. While the build-only approach is correct, contributors might benefit from a simple comment indicating the build succeeded (without registry details).

Optional: Add fork-specific build notification

You could add a separate, simpler comment step for fork PRs after the build completes:

- name: Comment build status (fork PR)
  if: always() && steps.fork_check.outputs.is_fork == 'true'
  uses: actions/github-script@v7
  with:
    script: |
      const shortSha = `${{ steps.short_sha.outputs.sha_short }}`;
      const jobStatus = `${{ job.status }}`;
      const marker = '<!-- docker-build-fork-comment -->';
      
      const message = jobStatus === 'success'
        ? `✅ Docker build succeeded for \`${shortSha}\` (validation only - not pushed to registry)`
        : `❌ Docker build failed for \`${shortSha}\``;
      
      github.rest.issues.createComment({
        owner: context.repo.owner,
        repo: context.repo.repo,
        issue_number: context.payload.pull_request.number,
        body: marker + '\n' + message
      });

154-164: Fork PRs skip ARM64 platform validation.

Fork PRs build only for linux/amd64, while non-fork PRs build for both linux/arm64 and linux/amd64. This means fork contributors won't discover ARM compatibility issues until after their PR is merged or a maintainer reviews it.

Consider whether ARM64 validation is important enough to include for fork PRs:

Option: Include both platforms for fork PRs
 - name: Build Docker image (fork PR - no push)
   if: steps.fork_check.outputs.is_fork == 'true'
   uses: docker/build-push-action@v6
   with:
     context: .
-    platforms: linux/amd64
+    platforms: linux/arm64,linux/amd64
     push: false
     build-args: |
       BUILDKIT_INLINE_CACHE=1

This will increase build time for fork PRs but provides better validation.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bcfc05b and dcfb8dd023c62e0df8f326d27588f9cacd517e56.

📒 Files selected for processing (1)
  • .github/workflows/docker-dev-images.yaml
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: HolmesGPT/holmesgpt PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-25T11:30:26.525Z
Learning: PRs require maintainer approval and pre-commit hooks must pass before merging
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build (3.10)
  • GitHub Check: llm_evals
  • GitHub Check: build
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.12)
🔇 Additional comments (4)
.github/workflows/docker-dev-images.yaml (4)

134-149: LGTM! Correct security-conscious gating.

The authentication and registry configuration steps are properly gated to run only for non-fork PRs. This prevents fork PRs from attempting operations they don't have permissions for and aligns with GitHub's security model for fork PRs.


166-177: LGTM! Multi-platform build and push configured correctly.

The non-fork PR build correctly targets both ARM64 and AMD64 platforms and pushes with appropriate tags. The conditional ensures this only runs when registry access is available.


186-282: LGTM! Comprehensive PR feedback for non-fork PRs.

The final comment step correctly:

  • Uses always() to provide feedback even on failure
  • Gates execution for non-fork PRs only
  • Calculates and displays build duration
  • Provides detailed registry information and deployment commands

The conditional logic ensures fork PRs don't attempt operations requiring write permissions.


24-32: The fork detection logic is correct as-is. The github.event.pull_request.head.repo.fork property is a boolean within the pull_request event context (which is this workflow's trigger), so it will never be null or undefined. The bash comparison [ "${{ github.event.pull_request.head.repo.fork }}" = "true" ] is the standard and appropriate way to check this property in GitHub Actions workflows.

@aantn
aantn force-pushed the claude/fix-github-actions-permissions-eK8xz branch from dcfb8dd to c57799c Compare December 28, 2025 09:34

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
.github/workflows/docker-dev-images.yaml (4)

24-32: Strengthen fork detection logic.

The current check assumes github.event.pull_request.head.repo.fork is either "true" or exists with a different value. For same-repo PRs, this property might be null, undefined, or missing entirely. While the else branch handles this implicitly, a more explicit comparison improves robustness.

🔎 Suggested improvement
     - name: Check if PR is from fork
       id: fork_check
       run: |
-        if [ "${{ github.event.pull_request.head.repo.fork }}" = "true" ]; then
+        if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
           echo "is_fork=true" >> $GITHUB_OUTPUT
           echo "📌 PR is from a fork - will build but not push"
         else
           echo "is_fork=false" >> $GITHUB_OUTPUT
         fi

This compares the full repository names, which is more explicit and reliable than checking the fork boolean property.


43-43: Consider UX for external contributors.

Skipping all PR comments for fork contributors means they won't receive any feedback about build status. While they can view logs directly in the Actions tab, a simple comment indicating "Build validation running (images won't be published for fork PRs)" would improve contributor experience.

💡 Suggested enhancement

Consider adding a lightweight comment for fork PRs:

    - name: Comment build started
      uses: actions/github-script@v7
      with:
        script: |
          const owner = context.repo.owner;
          const repo = context.repo.repo;
          const shortSha = `${{ steps.short_sha.outputs.sha_short }}`;
          const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${{ github.run_id }}`;
          const marker = '<!-- docker-build-comment -->';
          const isFork = '${{ steps.fork_check.outputs.is_fork }}' === 'true';
          
          let message;
          if (isFork) {
            message = [
              marker,
              `🔨 **Building Docker image for \`${shortSha}\` (fork PR - validation only)...**`,
              '',
              `[View build logs](${runUrl})`,
              '',
              '📌 Images from fork PRs are not published to the registry.',
            ].join('\n');
          } else {
            // ... existing non-fork message logic ...
          }
          // ... rest of comment posting logic ...

154-164: PR title doesn't match implementation.

The PR title states "Skip building images on PRs from external users (forks)" but the implementation actually builds images for forks—it just doesn't push them. This validates that fork PRs don't break the Dockerfile, which is valuable for maintainers reviewing external contributions.

Consider updating the PR title to "Build but don't push images for fork PRs" or similar to accurately reflect the behavior.

Also note that fork builds only target linux/amd64 while non-fork builds are multi-platform. This is a reasonable optimization for validation speed, but consider whether both platforms should be validated to catch platform-specific build issues early.


186-282: Fork PRs receive no build status feedback in PR comments.

Combined with skipping the "build started" comment (line 43), fork contributors receive no PR comments about build status—neither start, success, nor failure notifications. While they can view workflow logs in the Actions tab, this creates a less welcoming experience for external contributors.

Consider posting a lightweight success/failure comment for fork PRs, even if it doesn't include image push details.

💡 Example implementation
    - name: Comment with build status (fork PRs)
      if: always() && steps.fork_check.outputs.is_fork == 'true'
      uses: actions/github-script@v7
      with:
        script: |
          const shortSha = `${{ steps.short_sha.outputs.sha_short }}`;
          const jobStatus = `${{ job.status }}`;
          const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`;
          const marker = '<!-- docker-build-comment -->';
          
          const message = jobStatus === 'success'
            ? `${marker}\n✅ **Docker build validated for \`${shortSha}\`** (fork PR)\n\n📌 Images from fork PRs are not published.\n[View logs](${runUrl})`
            : `${marker}\n❌ **Docker build failed for \`${shortSha}\`**\n\n[View logs](${runUrl})`;
          
          // ... comment posting logic similar to lines 257-282 ...
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dcfb8dd023c62e0df8f326d27588f9cacd517e56 and c57799c3d61f016a388911bc7fd5c91ddddeb7f1.

📒 Files selected for processing (1)
  • .github/workflows/docker-dev-images.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.12)
  • GitHub Check: build
  • GitHub Check: llm_evals
🔇 Additional comments (2)
.github/workflows/docker-dev-images.yaml (2)

134-149: LGTM! Correct security boundary.

The conditionals properly skip authentication and registry configuration for fork PRs. Fork workflows don't have access to the OIDC token required for Google Cloud authentication, so these steps would fail anyway. This approach prevents unnecessary errors.


166-178: LGTM! Non-fork path preserved correctly.

The conditional ensures that non-fork PRs continue to build and push multi-platform images as before. The logic correctly maintains the existing behavior for internal contributors.

@aantn
aantn force-pushed the claude/fix-github-actions-permissions-eK8xz branch from c57799c to 93f5b74 Compare December 28, 2025 10:57

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/docker-dev-images.yaml (1)

43-43: Fork contributors receive no status comments.

The conditional correctly skips the build-started comment for fork PRs. However, fork contributors will have no visibility into build progress except through the GitHub Actions tab. While this aligns with the PR objective, consider adding a simple informational comment for fork PRs (e.g., "Build started - images will not be pushed for fork PRs") to improve contributor experience.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c57799c3d61f016a388911bc7fd5c91ddddeb7f1 and 93f5b743378b1e1a79540469662ebbdcea3b311e.

📒 Files selected for processing (1)
  • .github/workflows/docker-dev-images.yaml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build
  • GitHub Check: llm_evals
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.10)
🔇 Additional comments (4)
.github/workflows/docker-dev-images.yaml (4)

142-157: LGTM: Auth steps correctly gated.

The authentication, gcloud setup, and Docker registry configuration steps are all correctly gated to skip for fork PRs. This prevents unnecessary execution and potential confusing error messages, since fork PRs wouldn't have access to the required credentials due to GitHub's security model anyway.


162-172: LGTM: Fork PR build path correctly implemented.

The build-only step for fork PRs is correctly configured with push: false and a single platform (linux/amd64). This provides validation of the Dockerfile changes without attempting to push to the registry, and the single-platform build is a reasonable optimization for external contributions.


174-186: LGTM: Non-fork build and push correctly configured.

The multi-platform build and push step is properly gated to only run for non-fork PRs. The dual-platform build (linux/arm64,linux/amd64) and dual-tag strategy (full SHA and short SHA) provide comprehensive testing capabilities for maintainer PRs.


187-195: LGTM: Final steps correctly gated.

The image location print and final comment steps are correctly gated to skip for fork PRs. The use of always() combined with the fork check on line 195 ensures that non-fork PRs receive status updates (success or failure) while fork PRs are consistently excluded from the commenting flow.

Comment thread .github/workflows/docker-dev-images.yaml
Comment thread .github/workflows/docker-dev-images.yaml
For PRs from forks, GitHub automatically downgrades GITHUB_TOKEN to
read-only access for security.

Changes:
- Fork PRs: Build Docker image (no push) to verify the code compiles
- Fork PRs: Skip gcloud auth, registry config, and PR comments
- Non-fork PRs: Full build + push + PR comments (unchanged behavior)

GitHub automatically protects secrets for fork PRs - they are not
passed to workflows triggered by pull_request from forks.
@aantn
aantn force-pushed the claude/fix-github-actions-permissions-eK8xz branch from 93f5b74 to 80e8496 Compare December 29, 2025 07:27
@aantn
aantn enabled auto-merge (squash) December 29, 2025 07:53
@github-actions

Copy link
Copy Markdown
Contributor

Results of HolmesGPT evals

  • ask_holmes: 7/7 test cases were successful, 0 regressions
Test suite Test case Status
ask 09_crashpod ✅
ask 101_loki_historical_logs_pod_deleted ✅
ask 12_job_crashing ✅
ask 162_get_runbooks ✅
ask 176_network_policy_blocking_traffic_no_runbooks ✅
ask 43_current_datetime_from_prompt ✅
ask 61_exact_match_counting ✅

Legend

  • ✅ the test was successful
  • :minus: the test was skipped
  • ⚠️ the test failed but is known to be flaky or known to fail
  • 🚧 the test had a setup failure (not a code regression)
  • 🔧 the test failed due to mock data issues (not a code regression)
  • 🚫 the test was throttled by API rate limits/overload
  • ❌ the test failed and should be fixed before merging the PR

@aantn
aantn disabled auto-merge December 29, 2025 09:18
@aantn
aantn enabled auto-merge (squash) December 29, 2025 09:18
@aantn
aantn merged commit c35e334 into master Dec 29, 2025
10 of 11 checks passed
@aantn
aantn deleted the claude/fix-github-actions-permissions-eK8xz branch December 29, 2025 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants