Skip to content

chore(ci): update PR preview workflows to clean up on close - #1191

Open
KumarNirupam1 wants to merge 2 commits into
layer5io:masterfrom
KumarNirupam1:fix/pr-preview-closed-handling
Open

chore(ci): update PR preview workflows to clean up on close#1191
KumarNirupam1 wants to merge 2 commits into
layer5io:masterfrom
KumarNirupam1:fix/pr-preview-closed-handling

Conversation

@KumarNirupam1

@KumarNirupam1 KumarNirupam1 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Notes for Reviewers

This PR fixes the missing preview cleanup on PR close in the layer5io/docs preview workflows.

What changed

The PR preview workflows previously did nothing when a pull request was closed — the preview stayed on gh-pages until the retention prune removed it, and no comment was posted. This aligns the workflows with the audit checklist:

  • .github/workflows/build-docs-preview.yml
  • Added closed to the pull_request trigger types.
  • Gated the build steps (Harden, Checkout, Setup Go/Node, Install deps, Build) with if: github.event.action != 'closed' so a close only uploads the PR metadata, not a build.
  • Made the public/ upload path conditional on the event being a non-close.
  • .github/workflows/deploy-docs-preview.yml
  • Accepted closed in the metadata validation.
  • Deploy step now runs action: remove on close, action: deploy otherwise.
  • The sticky comment posts "Preview removed because the pull request was closed." on close and the existing preview-deployment message otherwise.

Why step-level gating

Gating individual steps (rather than the whole job) keeps the build workflow run completing as a success on close, so the workflow_run deploy still triggers and the cleanup/comment actually run.

Checklist

  • Build/deploy split preserved; PR code never runs in a privileged context.
  • wait-for-pages-deployment: false remains in place.
  • Actions remain SHA-pinned to their latest majors.
  • Preview comment message unchanged for non-close deployments (matches the shared template).
  • pull_request_target locations (report-only): labeler.yml, label-commenter.yml, copilot-pr-handler.yml.

Signed commits

  • Yes, I signed my commits.

Summary by CodeRabbit

  • Bug Fixes
    • Documentation previews are now automatically removed when a pull request is closed.
    • Closed pull requests no longer trigger unnecessary documentation builds or deployments.
    • Preview status comments now clearly indicate when a preview has been removed.

Signed-off-by: Kumar Nirupam <kumar.nirupam24@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@KumarNirupam1, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 34350038-a1db-466a-aa70-2bc9ff64695e

📥 Commits

Reviewing files that changed from the base of the PR and between 389cfb5 and 61f9775.

📒 Files selected for processing (1)
  • .github/workflows/build-docs-preview.yml
📝 Walkthrough

Walkthrough

The documentation preview workflows now handle closed pull requests. The build workflow uploads metadata without rebuilding preview content. The deploy workflow removes the preview and updates the pull request comment.

Changes

Documentation preview lifecycle

Layer / File(s) Summary
Closed-event build handling
.github/workflows/build-docs-preview.yml
The workflow accepts closed pull request events. It skips setup and preview generation for closed events. It uploads pull request metadata without the public directory.
Closed-event preview removal
.github/workflows/deploy-docs-preview.yml
The workflow accepts the closed action, removes the preview, and reports the removal in the pull request comment. Other accepted actions continue to deploy previews.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PullRequest
  participant BuildWorkflow
  participant DeployWorkflow
  participant PreviewAction
  participant PullRequestComment
  PullRequest->>BuildWorkflow: closed event
  BuildWorkflow->>DeployWorkflow: upload PR metadata
  DeployWorkflow->>PreviewAction: remove preview
  DeployWorkflow->>PullRequestComment: report preview removal
Loading

Possibly related PRs

  • layer5io/docs#1181: Extends the documentation preview workflows that this change updates.
  • layer5io/docs#1183: Also modifies the deploy workflow and pull request comment behavior.

Suggested reviewers: banana-three-join

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the workflow change to remove documentation previews when pull requests close.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@KumarNirupam1 KumarNirupam1 changed the title fix: remove preview and comment on PR close chore(ci): harden and update PR preview workflows Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Preview deployment: https://docs.layer5.io/pr-preview/pr-1191/

Note: Preview may take a moment (GitHub Pages deployment in progress). Please wait and refresh. Track deployment here

@KumarNirupam1 KumarNirupam1 changed the title chore(ci): harden and update PR preview workflows chore(ci): update PR preview workflows to clean up on close Aug 7, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/build-docs-preview.yml:
- Line 98: Update the artifact upload flow around the path expression to retain
public for closed pull requests while excluding the empty public/ directory from
uploaded files. Use an upload or filtering step that skips public only when the
PR is closed, preserving pr/ as the artifact root and ensuring uploads do not
fail when public/ has no files.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bf8a97f1-df81-44f9-acac-14dbad078484

📥 Commits

Reviewing files that changed from the base of the PR and between e907eea and 389cfb5.

📒 Files selected for processing (2)
  • .github/workflows/build-docs-preview.yml
  • .github/workflows/deploy-docs-preview.yml

Comment thread .github/workflows/build-docs-preview.yml Outdated
Signed-off-by: Kumar Nirupam <kumar.nirupam24@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant