Skip to content

Add PR preview pruning and retention management - #378

Open
Yashisinghal285 wants to merge 9 commits into
layer5io:masterfrom
Yashisinghal285:issue-377-preview-pruning
Open

Add PR preview pruning and retention management#378
Yashisinghal285 wants to merge 9 commits into
layer5io:masterfrom
Yashisinghal285:issue-377-preview-pruning

Conversation

@Yashisinghal285

Copy link
Copy Markdown
Contributor

Description

This PR adds preview pruning and retention management for PR preview deployments.

What changed

  • Adds PREVIEW_RETENTION_LIMIT = 6
  • Implements pruning of old pr-preview/pr-* directories
  • Uses sparse checkout for efficient gh-pages maintenance
  • Ensures only 6 most recent previews are kept
  • Adds notifications when previews are pruned
  • Preserves cleanup-on-close behavior

Issue

Fixes #377

Notes for Reviewers

  • Workflow runs after PR preview deployment
  • Only gh-pages pr-preview directory is modified
  • Safe for concurrent PR workflows

Checklist

  • I tested the workflow locally / validated syntax
  • I understand this modifies GitHub Actions behavior

Signed commits

  • Yes, I signed my commits

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

🚀 Preview deployment: https://layer5io.github.io/getnighthawk/pr-preview/pr-378/

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

@Yashisinghal285

Copy link
Copy Markdown
Contributor Author

Hi maintainers 👋
This PR implements preview pruning and retention management as per #377.
Ready for review when convenient.

@Yashisinghal285
Yashisinghal285 force-pushed the issue-377-preview-pruning branch from 831bd43 to 2732b56 Compare June 19, 2026 19:05
@Yashisinghal285

Copy link
Copy Markdown
Contributor Author

Hi maintainers 👋

I noticed the failing lint check appears to be timing out during package loading (context deadline exceeded).

This PR only modifies build-and-preview-site.yml and docs/_data/discuss/nighthawk.json, and does not modify .github/workflows/ci.yml, which runs the lint job.

Please let me know if you'd like any changes from my side or if there is anything else I can help investigate.

Thanks! 🙌

<center><h1>301 Moved Permanently</h1></center>
<hr><center>cloudflare</center>
</body>
</html>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What is use of changing this file.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Bhumikagarggg Thanks for pointing this out. This file wasn't intentionally modified as part of the preview pruning feature. It changed while I updated my branch and resolved the merge conflict with the latest master. The functional changes for this PR are only in build-and-preview-site.yml.

@Bhumikagarggg

Copy link
Copy Markdown

I approved this PR by mistake.


jobs:
build-and-deploy-preview:
outputs:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please move output section after runs-on

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Bhumikagarggg Done, thank you for the suggestion. I've moved the outputs section below runs-on as requested. Could you please take another look when you have a chance?


git add pr-preview
git commit -m "Prune old PR previews" || true
git push || true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Replace git push || true with git push instead of ignoring push failures.

@Yashisinghal285

Copy link
Copy Markdown
Contributor Author

@Sbragul26 Thanks for the review! I've updated the workflow by replacing git push || true with git push as suggested. Please take another look when you have a chance.

git config user.email "github-actions[bot]@users.noreply.github.com"

git add pr-preview
git commit -m "Prune old PR previews" || true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For this too replace git commit -m "Prune old PR previews" with this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! I've removed || true from the git commit command since the workflow already checks for staged changes before attempting the commit.

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git add pr-preview

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we remove this? git add pr-preview was already called above (line 123).

leecalcote and others added 7 commits July 2, 2026 17:27
Signed-off-by: l5io <ci@layer5.io>
Signed-off-by: Yashi Singhal285 <yashi.singhal410@gmail.com>
Signed-off-by: Yashi Singhal285 <yashi.singhal410@gmail.com>
Signed-off-by: l5io <ci@layer5.io>
Signed-off-by: Yashi Singhal285 <yashi.singhal410@gmail.com>
Signed-off-by: Yashi Singhal285 <yashi.singhal410@gmail.com>
Signed-off-by: Yashi Singhal285 <yashi.singhal410@gmail.com>
Signed-off-by: Yashi Singhal285 <yashi.singhal410@gmail.com>
Signed-off-by: Yashi Singhal285 <yashi.singhal410@gmail.com>
@Yashisinghal285
Yashisinghal285 force-pushed the issue-377-preview-pruning branch from cc111e9 to 43e2601 Compare July 2, 2026 11:58
@Yashisinghal285
Yashisinghal285 requested a review from Sbragul26 July 2, 2026 13:20

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I tested this PR, and it looks good to me. You can see the test PRs here: https://github.com/Bhumikagarggg/getnighthawk/pulls

However, I think we should remove the paths filter. In the future, if someone opens a PR with an empty or minimal change, the build-preview workflow may not run, which could cause preview pruning to miss that PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if a user pushes an empty commit (or a commit that doesn't modify any of the monitored paths) to re-trigger the preview after pruning, the build-preview workflow won't run.

Signed-off-by: Yashi Singhal285 <yashi.singhal410@gmail.com>
@Yashisinghal285
Yashisinghal285 force-pushed the issue-377-preview-pruning branch from 5b5597a to d0c1754 Compare July 2, 2026 23:08
@Yashisinghal285

Copy link
Copy Markdown
Contributor Author

Hi @Sbragul26, @Bhumikagarggg,

Just following up on this PR. I've addressed all the requested review comments, and the PR now has no merge conflicts and an approval. The remaining failing lint check appears to be unrelated to the changes in this PR.

Could you please let me know if anything else is required from my side? If everything looks good, I'd really appreciate it if this PR could be merged when you have time. Thank you!

@Yashisinghal285

Copy link
Copy Markdown
Contributor Author

Hi @Sbragul26, @Bhumikagarggg, @banana-three-join, @hortison 👋

Just a friendly follow-up on this PR. I've addressed all the requested review comments, the PR has an approval, and there are no merge conflicts. The remaining lint check appears to be unrelated to the changes in this PR.

If everything looks good, I'd really appreciate it if you could take a final look and merge it when you have time. Please let me know if there's anything else you'd like me to update.

Thank you!

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.

Add pruning for PR preview deployments

6 participants