Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

chore: compact gh-pages history (#2239)

David Petersen2eb9eeef6fa9
diff --git a/.github/scripts/compact-gh-pages-history.sh b/.github/scripts/compact-gh-pages-history.sh
new file mode 100755
index 0000000000..cdd379f0de
--- /dev/null
+++ b/.github/scripts/compact-gh-pages-history.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+
+set -euo pipefail
+
+PAGES_BRANCH="${PAGES_BRANCH:-gh-pages}"
+REPO="${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}"
+TOKEN="${GITHUB_TOKEN:?GITHUB_TOKEN is required}"
+REMOTE_URL="https://x-access-token:${TOKEN}@github.com/${REPO}.git"
+WORK_DIR="$(mktemp -d)"
+
+cleanup() {
+ rm -rf "${WORK_DIR}"
+}
+trap cleanup EXIT
+
+CURRENT_DIR="${WORK_DIR}/current"
+COMPACT_DIR="${WORK_DIR}/compact"
+
+git clone --depth=1 --single-branch --branch "${PAGES_BRANCH}" "${REMOTE_URL}" "${CURRENT_DIR}"
+OLD_HEAD="$(git -C "${CURRENT_DIR}" rev-parse HEAD)"
+
+mkdir -p "${COMPACT_DIR}"
+rsync -a --delete --exclude='.git' "${CURRENT_DIR}/" "${COMPACT_DIR}/"
+
+cd "${COMPACT_DIR}"
+git init -b "${PAGES_BRANCH}"
+git config user.name "github-actions[bot]"
+git config user.email "github-actions[bot]@users.noreply.github.com"
+git add -A
+git commit --allow-empty -m "chore: compact ${PAGES_BRANCH} history"
+git remote add origin "${REMOTE_URL}"
+git push origin "HEAD:refs/heads/${PAGES_BRANCH}" "--force-with-lease=refs/heads/${PAGES_BRANCH}:${OLD_HEAD}"
diff --git a/.github/workflows/compact-gh-pages.yml b/.github/workflows/compact-gh-pages.yml
new file mode 100644
index 0000000000..cc7a9b89af
--- /dev/null
+++ b/.github/workflows/compact-gh-pages.yml
@@ -0,0 +1,30 @@
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+
+name: Compact GitHub Pages History
+
+on:
+ schedule:
+ - cron: '17 9 * * 1' # Mondays at 09:17 UTC
+ workflow_dispatch:
+
+permissions: {}
+
+concurrency:
+ group: "pages-deploy"
+ cancel-in-progress: false
+
+jobs:
+ compact:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ steps:
+ - name: Checkout maintenance scripts
+ uses: actions/checkout@v6
+ with:
+ ref: main
+
+ - name: Compact gh-pages history
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: .github/scripts/compact-gh-pages-history.sh
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index 8abb72af76..b9295cbf91 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -13,8 +13,9 @@
# /index.html — landing page
# /latest — short hash of latest deploy
#
-# Uses keep_files:false — each deploy is a clean slate. PR previews and
-# reports are preserved by copying them from gh-pages before deploying.
+# Uses keep_files:false + force_orphan:true — each deploy is a clean slate.
+# PR previews and reports are preserved by copying them from gh-pages before
+# deploying, but old generated artifact history is not retained.
name: Deploy
on:
@@ -254,6 +255,7 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./deploy
keep_files: false
+ force_orphan: true
destination_dir: .
# Publish @xds/* packages to Metaccio (Meta's internal npm registry).