Skip to content

Commit 0b7869a

Browse files
committed
Push auto screenshots to the GitHub README on submit
Editor design ships persist the submitted screenshot but never re-pushed the GitHub README, so a circuit screenshot the maker never uploaded by hand only reached the repo if they went back and saved the project basics. Refresh the README from shipProjectFromForm right after the ship persists, gated to auto screenshots (/auto.png) so a hand-uploaded shot still publishes via the edit-modal save path instead. Scheduled with after() and best-effort, so it doesn't block the submit or touch repos we don't own.
1 parent 976e8fa commit 0b7869a

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/actions/projects.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use server";
22

33
import { revalidatePath } from "next/cache";
4+
import { after } from "next/server";
45
import { z } from "zod";
56
import type { HackClubClaims } from "@/lib/auth/hackclub";
67
import { assertHackClubYswsEligible, ensureSlackId } from "@/lib/auth/hackclub";
@@ -28,6 +29,10 @@ import {
2829
getUnjournaledSeconds,
2930
JOURNAL_MIN_SECONDS,
3031
} from "@/lib/editor/journal-time";
32+
import {
33+
refreshGitHubReadme,
34+
resolvePublicOrigin,
35+
} from "@/lib/projects/githubReadme";
3136
import {
3237
fetchTimelapsesForUser,
3338
lapseProgramKeyConfigured,
@@ -446,6 +451,18 @@ export async function shipProjectFromForm(
446451
projectId,
447452
data,
448453
);
454+
// An auto-generated circuit screenshot the maker never uploaded by hand
455+
// only reaches the repo if we push it: shipProjectForUser has persisted it
456+
// to the project row, so refresh the published GitHub README now. Limited
457+
// to auto screenshots ("/auto.png") on purpose. A hand-uploaded shot is the
458+
// maker's to publish via the edit-modal save, so we don't auto-push it here.
459+
// Scheduled with after() so the submit response doesn't wait on the GitHub
460+
// round-trip; refreshGitHubReadme never throws and skips repos we don't own.
461+
// Origin is resolved here because headers() is gone in after().
462+
if (data.screenshotUrl.endsWith("/auto.png")) {
463+
const origin = await resolvePublicOrigin();
464+
after(() => refreshGitHubReadme(projectId, session.user.id, origin));
465+
}
449466
await notifyReviewSubmitted(projectId, "materials");
450467
await syncUserToLoops(session.user.id);
451468
revalidatePath("/platform/projects");

0 commit comments

Comments
 (0)