Skip to content

feat(ci): run storybook cleanup daily#20332

Merged
MagentaManifold merged 1 commit intomainfrom
feat-storybook-cleanup-daily
Apr 7, 2026
Merged

feat(ci): run storybook cleanup daily#20332
MagentaManifold merged 1 commit intomainfrom
feat-storybook-cleanup-daily

Conversation

@MagentaManifold
Copy link
Copy Markdown
Contributor

@MagentaManifold MagentaManifold commented Apr 7, 2026

Because

  • sometimes a cleanup job gets canceled due to concurrency settings

This pull request

  • turns storybook cleanup into a daily cronjob that searches through all PRs stored and clean up closed ones

Issue that this pull request solves

Closes: (issue number)

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).
  • I have manually reviewed all AI generated code.

How to review (Optional)

  • Key files/areas to focus on:
  • Suggested review order:
  • Risky or complex parts: Sadly we can't test it out without merging it first, but once its merged we should be able to trigger it manually (we have a few closed PRs that aren't cleaned up)

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

Rational of this PR:

  • any closed PRs eventually gets cleaned up instead of clogging in the build forever.
  • reduces cleanup job runs to once per day instead of per closed PR, further reducing the possibility of jobs getting canceled due to concurrency setting; it should also save some cost.

@MagentaManifold MagentaManifold requested a review from a team as a code owner April 7, 2026 18:50
Copilot AI review requested due to automatic review settings April 7, 2026 18:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Storybook cleanup GitHub Actions workflow so cleanup isn’t dependent on a PR-close event (which can be skipped/canceled due to concurrency), and instead runs on a daily schedule with an optional manual trigger.

Changes:

  • Switch workflow trigger from pull_request: closed to a daily schedule cron plus workflow_dispatch.
  • Replace single-PR deletion logic with a loop that scans gh-pages/storybooks/pr-* and deletes entries for closed (or missing) PRs via the GitHub API.
  • Avoid unnecessary forced pushes by skipping the push when git status shows no changes, and align index generation env var usage with existing workflows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/cleanup-storybooks.yml
Comment thread .github/workflows/cleanup-storybooks.yml
@MagentaManifold MagentaManifold force-pushed the feat-storybook-cleanup-daily branch from a42890a to 3462bab Compare April 7, 2026 19:02
[ -d "$dir" ] || continue
PR_NUMBER=$(basename "$dir" | sed 's/^pr-//')
STATE=$(gh api "repos/${REPO}/pulls/${PR_NUMBER}" --jq '.state')
if [ "$STATE" = "closed" ] || [ "$STATE" = "not_found" ]; then
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.

It looks like state can only be open or closed - if the PR never existed, then this would result in a 404 (not handled here). Unlikely scenario since the storybook folders are generated from a PR in the first place, but we probably want to either specifically handle the 404 or remove the "not_found" state.

Because:

* sometimes a cleanup job gets cancelled due to concurrency settings

This commit:

* turns storybook cleanup into a daily cronjob that searches through all PRs stored and cleanup closed ones
@MagentaManifold MagentaManifold force-pushed the feat-storybook-cleanup-daily branch from 3462bab to e6e457d Compare April 7, 2026 21:33
@MagentaManifold MagentaManifold merged commit 060c1a8 into main Apr 7, 2026
14 of 20 checks passed
@MagentaManifold MagentaManifold deleted the feat-storybook-cleanup-daily branch April 7, 2026 21:53
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.

3 participants