Skip to content

Meta: remove PR preview when PR is closed#3824

Open
bakkot wants to merge 1 commit intotc39:mainfrom
bakkot:rm-old-previews
Open

Meta: remove PR preview when PR is closed#3824
bakkot wants to merge 1 commit intotc39:mainfrom
bakkot:rm-old-previews

Conversation

@bakkot
Copy link
Copy Markdown
Member

@bakkot bakkot commented Apr 9, 2026

Per https://matrixlogs.bakkot.com/TC39_Editors/2026-04-08#L22.

Claude wrote this but seems fine.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

The rendered spec preview for this PR is available as a single page at https://tc39.es/ecma262/pr/3824 and as multiple pages at https://tc39.es/ecma262/pr/3824/multipage .

@rbuckton
Copy link
Copy Markdown
Contributor

rbuckton commented Apr 9, 2026

I wonder if publishing the generated PR as a build artifact could be used in place of the gh-pages branch. Build artifacts already have a lifetime that's tied to how long the workflow is retained.

https://github.blog/changelog/2026-02-26-github-actions-now-supports-uploading-and-downloading-non-zipped-artifacts/

Per actions/upload-artifact#14 it only currently supports single files though, so it could be tricky to use.

with:
ref: gh-pages

- name: Delete PR preview directory
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.

This would also need to be queued to prevent collisions with publishing as in #3821

@bakkot
Copy link
Copy Markdown
Member Author

bakkot commented Apr 9, 2026

AFAIK build artifacts cannot be viewed as webpages online, which is the purpose of the previews.

@rbuckton
Copy link
Copy Markdown
Contributor

rbuckton commented Apr 9, 2026

AFAIK build artifacts cannot be viewed as webpages online, which is the purpose of the previews.

That's supposedly the point of the change to artifacts from the blog post I linked to.

@bakkot
Copy link
Copy Markdown
Member Author

bakkot commented Apr 9, 2026

Oh, neat. Yeah, that would work, ecmarkup is capable of inlining all the assets if we ask it to. Maybe for the future though.

(Edit: oh, though, that would mean no multipage previews, which would be shame.)

@michaelficarra
Copy link
Copy Markdown
Member

We'll also need to do a one-time culling after this lands. Do you have a script to do that?

Also, I'd love (for someone else) to explore using artifacts as @rbuckton suggests and get away from this whole custom gh-pages thing ASAP.

@bakkot
Copy link
Copy Markdown
Member Author

bakkot commented Apr 9, 2026

Claude has such a script, sure. I can send a PR removing the dead ones once this lands.

said script
#!/bin/bash

set -euo pipefail

cd "$(dirname "$BASH_SOURCE")"/..

REPO="${GITHUB_REPOSITORY:-tc39/ecma262}"

echo "Cloning gh-pages branch..."
rm -rf gh-pages-cleanup
git clone --depth 1 --branch gh-pages "https://github.com/${REPO}.git" gh-pages-cleanup

cd gh-pages-cleanup

if [ ! -d pr ]; then
  echo "No pr/ directory found."
  rm -rf ../gh-pages-cleanup
  exit 0
fi

to_remove=()
for dir in pr/*/; do
  pr_number="$(basename "$dir")"
  if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then
    continue
  fi

  state="$(gh pr view "$pr_number" --repo "$REPO" --json state --jq .state 2>/dev/null || echo "UNKNOWN")"
  if [ "$state" != "OPEN" ]; then
    echo "PR #$pr_number is $state — will remove"
    to_remove+=("pr/$pr_number")
  else
    echo "PR #$pr_number is open — keeping"
  fi
done

if [ ${#to_remove[@]} -eq 0 ]; then
  echo "Nothing to clean up."
  rm -rf ../gh-pages-cleanup
  exit 0
fi

git config user.email "bot@tc39"
git config user.name "Bot"
git rm -rf "${to_remove[@]}"
git commit --message "Remove gh-pages previews for closed PRs"

echo ""
echo "Ready to push. Run:"
echo "  cd gh-pages-cleanup && git push origin gh-pages && cd .. && rm -rf gh-pages-cleanup"

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