Add bilingual private-safe activity heatmap and scoped prune-free CI
Deploy Frontend / deploy (push) Successful in 7m48s

This commit is contained in:
Hermes Agent committed 2026-11-18 13:49:14 +00:00
1 parent 48d9a30ddf
commit 12a79b38de
9 files changed
+131 -2

No files matched your search

+19 -2
View File
@@ -24,5 +24,22 @@ jobs:
echo "$SSH_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -p 2234 -H 172.17.0.1 >> ~/.ssh/known_hosts
- name: Deploy
run: ssh -p 2234 devops@172.17.0.1 'bash /opt/services/parsa/frontend/deploy.sh'
- name: Deploy reviewed scoped frontend release
env:
RELEASE_SHA: ${{ gitea.sha }}
run: |
case "$RELEASE_SHA" in ''|*[!0-9a-f]*) exit 1;; esac
test "${#RELEASE_SHA}" = 40
ssh -p 2234 devops@172.17.0.1 "bash -s -- $RELEASE_SHA" <<'REMOTE'
set -euo pipefail
expected=$1
cd /opt/services/parsa/frontend/repo
test -z "$(git status --porcelain --untracked-files=normal)"
export GIT_SSH_COMMAND='ssh -i /home/devops/.ssh/deploy_key -o StrictHostKeyChecking=no'
git fetch origin main
test "$(git rev-parse origin/main)" = "$expected"
git merge --ff-only "$expected"
bash -n ops/deploy-frontend.sh
sudo install -m 0755 ops/deploy-frontend.sh /opt/services/parsa/frontend/deploy.sh
bash /opt/services/parsa/frontend/deploy.sh "$expected"
REMOTE
+16
View File
@@ -0,0 +1,16 @@
FROM node:22-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --ignore-scripts --registry=https://registry.npmjs.org
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
FROM node:22-alpine
WORKDIR /app
ENV NODE_ENV=production NEXT_TELEMETRY_DISABLED=1 PORT=3000 HOSTNAME=0.0.0.0
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
USER node
EXPOSE 3000
CMD ["node", "server.js"]
+17
View File
@@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail
expected=${1:?immutable revision required}
[[ "$expected" =~ ^[0-9a-f]{40}$ ]]
cd /opt/services/parsa/frontend/repo
test "$(git rev-parse HEAD)" = "$expected"
test -z "$(git status --porcelain --untracked-files=normal)"
export PARSA_RELEASE_SHA="$expected"
DOCKER_BUILDKIT=0 docker compose -f /opt/services/parsa/frontend/compose.yml -f ops/frontend.compose.yml build frontend
docker compose -f /opt/services/parsa/frontend/compose.yml -f ops/frontend.compose.yml up -d --no-deps --no-build frontend
for i in {1..40}; do
if [ "$(curl --max-time 15 -fsS https://parsaaghayi.ir/api/revision || true)" = "$expected" ]; then
echo "Frontend verified revision: $expected"; exit 0
fi
sleep 3
done
exit 1
+8
View File
@@ -0,0 +1,8 @@
services:
frontend:
build:
dockerfile: /opt/services/parsa/frontend/repo/ops/Dockerfile
environment:
PARSA_RELEASE_SHA: ${PARSA_RELEASE_SHA:?required}
labels:
org.opencontainers.image.revision: ${PARSA_RELEASE_SHA:?required}
+13
View File
@@ -0,0 +1,13 @@
import { render, screen, fireEvent } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import ActivityGrid, { ActivityData } from '../app/(routes)/(website)/components/activity/activity-grid';
const data: ActivityData = {
timezone: 'Asia/Tehran', from: '2025-11-19', to: '2026-11-18', updated_at: '2026-11-18T10:00:00+03:30',
days: Array.from({length:365}, (_, i) => ({ date: new Date(Date.UTC(2025,10,19+i)).toISOString().slice(0,10), count: i === 364 ? 3 : 0 })),
stats: {total:3, active_days:1, daily_average:0.01, longest_streak:1}, months:[{month:'2026-11',count:3}]
};
describe('Activity aggregate view (isolated fixtures)', () => {
it('shows honest unavailable without invented statistics', () => { render(<ActivityGrid data={null} locale="en" />); expect(screen.getByRole('status')).toHaveTextContent('unavailable'); expect(screen.queryByText('Active days')).not.toBeInTheDocument(); });
it('renders daily accessible selection and real supplied stats', () => { const {container}=render(<ActivityGrid data={data} locale="en" />); const days=screen.getAllByRole('button'); expect(days).toHaveLength(365); fireEvent.click(days[364]); expect(container.querySelector('[aria-live]')).toHaveTextContent('3 contributions'); expect(screen.getByText('Daily average')).toBeInTheDocument(); });
it('renders Persian with RTL and translated state', () => {const {container}=render(<ActivityGrid data={data} locale="fa" />); expect(container.querySelector('section')).toHaveAttribute('dir','rtl'); expect(screen.getByText('روز فعال')).toBeInTheDocument(); });
});
@@ -4,6 +4,7 @@ import AboutMe from "../components/aboutMe/aboutMe";
import Services from "../components/services/services";
import MyProjects from "../components/projects/projects";
import Hero from "../components/hero/hero";
import Activity from "../components/activity/activity";
import { getDictionary } from "@/app/lib/functions/dictionaries";
import { getDefaultLocale } from "@/app/lib/functions/utils";
import { Metadata } from "next";
@@ -64,6 +65,7 @@ export default async function Home() {
<div className="flex w-full max-w-[1420px] flex-col items-center gap-[100px] py-20 px-6">
<Hero dict={dict} />
<AboutMe />
<Activity locale={locale} />
<Services dict={dict} initialServices={initialData.services} />
<MyProjects
dict={dict}
@@ -0,0 +1,40 @@
"use client";
import { useState } from "react";
export type ActivityData = {
timezone: string; from: string; to: string; updated_at: string;
days: { date: string; count: number }[];
stats: { total: number; active_days: number; daily_average: number; longest_streak: number };
months: { month: string; count: number }[];
};
export default function ActivityGrid({ data, locale }: { data: ActivityData | null; locale: string }) {
const fa = locale === "fa";
const [selected, setSelected] = useState<string | null>(null);
const number = new Intl.NumberFormat(fa ? "fa-IR" : "en-US");
const date = (value: string) => new Intl.DateTimeFormat(fa ? "fa-IR" : "en-GB", { dateStyle: "medium", timeZone: "Asia/Tehran" }).format(new Date(value + "T12:00:00+03:30"));
const valid = data && Array.isArray(data.days) && data.days.length === 365 && data.stats && Array.isArray(data.months);
const dayLabel = (day: { date: string; count: number }) => `${date(day.date)} — ${number.format(day.count)} ${fa ? "مشارکت" : "contributions"}`;
const tones = ["bg-muted", "bg-orange-200 dark:bg-orange-950", "bg-orange-300 dark:bg-orange-800", "bg-orange-500", "bg-orange-700 dark:bg-orange-400"];
return <section aria-labelledby="activity-title" className="w-full min-w-0 rounded-3xl border bg-card p-5 md:p-9" dir={fa ? "rtl" : "ltr"}>
<p className="text-sm font-mono text-muted-foreground">GITEA / {fa ? "فعالیت مهندسی" : "ENGINEERING ACTIVITY"}</p>
<h2 id="activity-title" className="mt-3 text-2xl font-bold md:text-3xl">{fa ? "یک سال ساختن، روز به روز" : "A year of building, day by day"}</h2>
<p className="mt-3 text-sm leading-7 text-muted-foreground">{fa ? "مشارکت‌های عمومی و خصوصی؛ فقط تعداد روزانه، بدون نام یا محتوای مخزن. ۳۶۵ روز اخیر بر اساس زمان تهران. مشارکت با تعداد کامیت برابر نیست." : "Public and private contributions, shared only as daily counts. No repository names or content. Last 365 days in Tehran time; contributions are not commit counts."}</p>
{!valid ? <p role="status" className="mt-6 rounded-xl border p-5 text-sm">{fa ? "اطلاعات فعالیت اکنون در دسترس نیست. لطفاً بعداً صفحه را تازه کنید." : "Activity is unavailable right now. Please refresh later."}</p> : <>
<dl className="my-7 grid grid-cols-2 gap-4 lg:grid-cols-4">{[
[fa ? "مشارکت" : "Contributions", data.stats.total],
[fa ? "روز فعال" : "Active days", data.stats.active_days],
[fa ? "میانگین روزانه" : "Daily average", data.stats.daily_average],
[fa ? "طولانی‌ترین زنجیره روزانه" : "Longest daily streak", data.stats.longest_streak],
].map(([label, value]) => <div key={label} className="rounded-xl bg-muted/50 p-4"><dt className="text-sm text-muted-foreground">{label}</dt><dd className="mt-2 text-2xl font-bold tabular-nums">{number.format(Number(value))}</dd></div>)}</dl>
<div className="overflow-x-auto pb-3" dir="ltr" aria-label={fa ? "تقویم مشارکت؛ برای مشاهده جزئیات روز را انتخاب کنید" : "Contribution calendar; select a day for details"} tabIndex={0}>
<div className="grid w-max grid-flow-col grid-rows-7 gap-1 p-1" style={{ gridTemplateColumns: "repeat(53, 12px)" }}>
{Array.from({ length: new Date(data.from + "T12:00:00Z").getUTCDay() }, (_, i) => <span key={`pad-${i}`} />)}
{data.days.map(day => <button type="button" key={day.date} aria-label={dayLabel(day)} title={dayLabel(day)} onFocus={() => setSelected(day.date)} onClick={() => setSelected(day.date)} className={`h-3 w-3 rounded-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary ${tones[day.count === 0 ? 0 : day.count < 3 ? 1 : day.count < 6 ? 2 : day.count < 10 ? 3 : 4]}`} />)}
</div>
</div>
<p aria-live="polite" className="mt-3 min-h-7 text-sm">{selected ? dayLabel(data.days.find(d => d.date === selected)!) : fa ? "برای جزئیات، یک روز را انتخاب کنید. برای دیدن تمام سال به کناره‌ها پیمایش کنید." : "Select a day for details. Scroll sideways to explore the full year."}</p>
<div className="mt-2 flex items-center gap-2 text-sm text-muted-foreground"><span>{fa ? "کمتر" : "Less"}</span>{tones.map(tone => <span key={tone} className={`h-3 w-3 rounded-sm ${tone}`} />)}<span>{fa ? "بیشتر" : "More"}</span></div>
<details className="mt-6 border-t pt-4 text-sm"><summary className="cursor-pointer py-2 font-medium">{fa ? "مجموع ماهانه (ماه‌های میلادی)" : "Monthly totals (Gregorian months)"}</summary><dl className="mt-4 grid grid-cols-2 gap-3 md:grid-cols-4">{data.months.map(month => <div key={month.month} className="flex justify-between gap-4 rounded-lg bg-muted/50 p-3"><dt dir="ltr">{month.month}</dt><dd>{number.format(month.count)}</dd></div>)}</dl></details>
<p className="mt-5 text-sm leading-7 text-muted-foreground">{date(data.from)} — {date(data.to)} · {fa ? "آخرین دریافت:" : "Fetched:"} {new Intl.DateTimeFormat(fa ? "fa-IR" : "en-GB", { dateStyle: "medium", timeStyle: "short", timeZone: "Asia/Tehran" }).format(new Date(data.updated_at))} · {fa ? "زمان تهران · تازه‌سازی تا ۵ دقیقه" : "Tehran time · refreshes within 5 minutes"}</p>
</>}
</section>;
}
@@ -0,0 +1,12 @@
import ActivityGrid, { ActivityData } from "./activity-grid";
export default async function Activity({ locale }: { locale: string }) {
let data: ActivityData | null = null;
try {
const response = await fetch("https://backend.parsaaghayi.ir/api/website/activity", {
cache: "no-store", signal: AbortSignal.timeout(12000),
});
if (response.ok) data = await response.json();
} catch { /* Honest unavailable state; no synthetic activity. */ }
return <ActivityGrid data={data} locale={locale} />;
}
+4
View File
@@ -0,0 +1,4 @@
export const dynamic = "force-dynamic";
export function GET() {
return new Response(process.env.PARSA_RELEASE_SHA || "development", { headers: { "Content-Type": "text/plain", "Cache-Control": "no-store" } });
}