ci: keep site updates out of app releases

This commit is contained in:
lucaronin
2026-05-07 10:35:00 +02:00
parent abc6f7d9b1
commit efd3ff3132
4 changed files with 144 additions and 3 deletions

View File

@@ -4,6 +4,11 @@ on:
push:
branches:
- main
paths-ignore:
- ".husky/**"
- ".github/workflows/deploy-docs.yml"
- ".github/workflows/release.yml"
- "site/**"
env:
# Bump this when Tauri/Rust target artifacts capture stale absolute paths.

View File

@@ -40,8 +40,36 @@ ensure_node_tooling
echo "🔍 Pre-commit checks..."
STAGED_FILES=$(git diff --cached --name-only)
APP_CHANGED=false
SITE_CHANGED=false
for FILE in $STAGED_FILES; do
case "$FILE" in
site/*)
SITE_CHANGED=true
;;
.github/workflows/*|.husky/*|docs/*|*.md)
;;
*)
APP_CHANGED=true
;;
esac
done
if [ "$APP_CHANGED" = false ]; then
if [ "$SITE_CHANGED" = true ]; then
echo " → docs build..."
pnpm docs:build
else
echo " → app checks skipped (docs/workflow/hooks only)"
fi
echo "✅ Pre-commit passed"
exit 0
fi
# Lint + types (only if TS files staged)
STAGED_TS=$(git diff --cached --name-only | grep -E '\.(ts|tsx)$' || true)
STAGED_TS=$(echo "$STAGED_FILES" | grep -E '\.(ts|tsx)$' || true)
if [ -n "$STAGED_TS" ]; then
echo " → lint + tsc..."
pnpm lint --quiet

View File

@@ -95,12 +95,43 @@ echo "================================================"
# ── Detect what changed ─────────────────────────────────────────────────
PUSH_TARGET=$(git rev-parse @{push} 2>/dev/null || echo "")
RUST_CHANGED=true
APP_CHANGED=true
SITE_CHANGED=false
if [ -n "$PUSH_TARGET" ]; then
CHANGED=$(git diff --name-only "$PUSH_TARGET"..HEAD)
APP_CHANGED=false
if ! echo "$CHANGED" | grep -qE '^(src-tauri/|Cargo)'; then
RUST_CHANGED=false
fi
for FILE in $CHANGED; do
case "$FILE" in
site/*)
SITE_CHANGED=true
;;
.github/workflows/*|.husky/*|docs/*|*.md)
;;
*)
APP_CHANGED=true
;;
esac
done
fi
if [ "$APP_CHANGED" = false ]; then
if [ "$SITE_CHANGED" = true ]; then
echo ""
echo "📚 Docs-only push detected; running docs build..."
pnpm docs:build
echo " ✅ Docs build OK"
else
echo ""
echo "⏭️ App checks skipped (docs/workflow/hooks only)"
fi
ELAPSED=$(($(date +%s) - START_TIME))
echo ""
echo "✅ Pre-push passed in ${ELAPSED}s"
exit 0
fi
# ── 0. TypeScript + Vite build ──────────────────────────────────────────

View File

@@ -1,10 +1,22 @@
<script setup lang="ts">
import DefaultTheme from "vitepress/theme";
import { onBeforeUnmount, onMounted, watchEffect } from "vue";
import { onBeforeUnmount, onMounted, ref, watchEffect } from "vue";
import { useData } from "vitepress";
const { frontmatter } = useData();
const githubStars = "9,946";
const fallbackGithubStars = "9,946";
const githubStars = ref(fallbackGithubStars);
const githubStarsCacheKey = "tolaria:github-stars";
const githubStarsCacheTtlMs = 60 * 60 * 1000;
const githubRepoApiUrl = "https://api.github.com/repos/refactoringhq/tolaria";
type GithubStarsCache = {
stars: number;
savedAt: number;
};
const formatGithubStars = (stars: number) =>
new Intl.NumberFormat("en-US").format(stars);
const scrollClass = "tolaria-scrolled";
const landingPageClass = "tolaria-landing-page";
@@ -12,6 +24,70 @@ const updateScrollClass = () => {
document.documentElement.classList.toggle(scrollClass, window.scrollY > 8);
};
const readCachedGithubStars = (): GithubStarsCache | null => {
try {
const rawCache = window.localStorage.getItem(githubStarsCacheKey);
if (!rawCache) {
return null;
}
const parsedCache = JSON.parse(rawCache) as Partial<GithubStarsCache>;
if (
typeof parsedCache.stars !== "number" ||
typeof parsedCache.savedAt !== "number" ||
!Number.isFinite(parsedCache.stars) ||
!Number.isFinite(parsedCache.savedAt)
) {
return null;
}
return {
stars: parsedCache.stars,
savedAt: parsedCache.savedAt,
};
} catch {
return null;
}
};
const updateGithubStars = async () => {
const cachedStars = readCachedGithubStars();
if (cachedStars) {
githubStars.value = formatGithubStars(cachedStars.stars);
if (Date.now() - cachedStars.savedAt < githubStarsCacheTtlMs) {
return;
}
}
try {
const response = await fetch(githubRepoApiUrl, {
headers: { Accept: "application/vnd.github+json" },
});
if (!response.ok) {
return;
}
const repo = (await response.json()) as { stargazers_count?: unknown };
if (
typeof repo.stargazers_count !== "number" ||
!Number.isFinite(repo.stargazers_count)
) {
return;
}
window.localStorage.setItem(
githubStarsCacheKey,
JSON.stringify({
stars: repo.stargazers_count,
savedAt: Date.now(),
} satisfies GithubStarsCache),
);
githubStars.value = formatGithubStars(repo.stargazers_count);
} catch {
// Keep the cached or bundled fallback count.
}
};
watchEffect(() => {
if (typeof document === "undefined") {
return;
@@ -25,6 +101,7 @@ watchEffect(() => {
onMounted(() => {
updateScrollClass();
void updateGithubStars();
window.addEventListener("scroll", updateScrollClass, { passive: true });
});