fix: make homepage metrics deployment reliable - #71
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
rustfs-com | 1ea3bfc | Commit Preview URL Branch Preview URL |
Aug 01 2026, 05:18 PM |
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make homepage metrics collection more reliable during deployments by injecting pre-fetched GitHub/Docker metrics into the build, increasing fetch timeouts, and optionally failing the build if live metrics cannot be obtained.
Changes:
- Add a CI script to fetch GitHub + Docker Hub metrics and export them via
GITHUB_ENV. - Allow
lib/github.tsandlib/docker.tsto consume injected metrics from environment variables, with updated fallback behavior and stricter failure mode when required. - Update the deploy workflow to fetch metrics before building and enforce live-metrics requirements during the build step.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| scripts/fetch-homepage-metrics.sh | New script to fetch metrics from GitHub GraphQL + Docker Hub API and inject them into subsequent workflow steps. |
| lib/github.ts | Adds injected-metrics support and a shared fallback; can hard-fail when live metrics are required. |
| lib/docker.ts | Adds injected-metrics support, fallback constants, longer timeouts, and optional hard-fail behavior. |
| .github/workflows/deploy.yml | Runs the metrics fetch step before build and sets REQUIRE_LIVE_HOMEPAGE_METRICS during the build. |
Suppressed comments (1)
scripts/fetch-homepage-metrics.sh:27
- These jq guards treat a metric value of 0 as invalid ("> 0"), but 0 is a valid count for stars/forks/commits/pulls (e.g., a new repo). This can cause the workflow to fail unnecessarily.
stars="$(jq -er '.data.repository.stargazerCount | if type == "number" and . > 0 then . else error("invalid stars") end' <<<"${github_metrics}")"
forks="$(jq -er '.data.repository.forkCount | if type == "number" and . > 0 then . else error("invalid forks") end' <<<"${github_metrics}")"
commits="$(jq -er '.data.repository.defaultBranchRef.target.history.totalCount | if type == "number" and . > 0 then . else error("invalid commits") end' <<<"${github_metrics}")"
docker_pulls="$(jq -er '.results[] | select(.name == "rustfs") | .pull_count | if type == "number" and . > 0 then . else error("invalid Docker pulls") end' <<<"${docker_metrics}")"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+11
to
+14
| -H "Accept: application/vnd.github+json" \ | ||
| -H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
| -H "User-Agent: RustFS-Website" \ | ||
| --data-binary '{"query":"query { repository(owner: \"rustfs\", name: \"rustfs\") { stargazerCount forkCount defaultBranchRef { target { ... on Commit { history { totalCount } } } } } }"}' \ |
Comment on lines
+13
to
+16
| const injectedPulls = Number(injectedPullsValue); | ||
| if (Number.isInteger(injectedPulls) && injectedPulls > 0) { | ||
| return injectedPulls; | ||
| } |
| commits: Number(injectedMetricValues[2]), | ||
| }; | ||
|
|
||
| if (Object.values(injectedMetrics).every((value) => Number.isInteger(value) && value > 0)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: make homepage metrics deployment reliable