Skip to content

Commit 458eaf5

Browse files
committed
feat(ci): compute source commit date and pass to NEXT_PUBLIC_BUILD_DATE
1 parent cfd022c commit 458eaf5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Dockerfile.web

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ COPY --from=builder /app/out/full/ .
4444
# Write env vars to .env file for Next.js to read at build time
4545
RUN printenv | grep -E '^(DATABASE_URL|JWT_SECRET|NEXT_PUBLIC_|PRIVATE_KEY_|S3_|SENTRY_|SLACK_|UPLOAD_TOKEN_)' > ./apps/web/.env || true
4646

47+
# Fetch commit timestamp from GitHub API and set as build date
48+
RUN if [ -n "$SOURCE_COMMIT" ]; then \
49+
COMMIT_DATE=$(curl -sf "https://api.github.com/repos/hackclub/lapse/commits/$SOURCE_COMMIT" | grep -m1 '"date"' | head -1 | sed 's/.*"\([^"]*\)".*/\1/'); \
50+
if [ -n "$COMMIT_DATE" ]; then \
51+
TIMESTAMP_MS=$(($(date -d "$COMMIT_DATE" +%s) * 1000)); \
52+
echo "NEXT_PUBLIC_BUILD_DATE=$TIMESTAMP_MS" >> ./apps/web/.env; \
53+
fi; \
54+
fi
55+
4756
RUN --mount=type=cache,id=prisma-cache,target=/root/.cache/prisma \
4857
--mount=type=cache,id=pnpm-cache,target=/root/.local/share/pnpm \
4958
NODE_ENV=production pnpm turbo run build

0 commit comments

Comments
 (0)