feat: add CI status badge with commit SHA on homelab experience card
Build & Push Portfolio Image / build-push (push) Successful in 4m8s

This commit is contained in:
Story Crater Bot
2026-09-02 20:30:21 -07:00
parent c33185533b
commit b3631211af
3 changed files with 64 additions and 7 deletions
+2
View File
@@ -63,3 +63,5 @@ jobs:
docker push "${IMAGE}:${{ steps.sha.outputs.short_sha }}"
docker push "${IMAGE}:latest"
echo "✓ Image pushed: ${IMAGE}:${{ steps.sha.outputs.short_sha }}"
+10 -4
View File
@@ -1,9 +1,14 @@
import { NextResponse } from 'next/server'
import { NextRequest, NextResponse } from 'next/server'
const FORGEJO_URL = 'https://forgejo.riotpiao.com'
const REPO = 'rock/riotpiao.com'
const DEFAULT_REPO = 'rock/riotpiao.com'
const ALLOWED_REPOS = ['rock/riotpiao.com', 'rock/homelab', 'rock/homelab-frontend', 'rock/poimen', 'rock/poimen-memory', 'rock/poimen-workflows']
export async function GET() {
export async function GET(request: NextRequest) {
const repo = request.nextUrl.searchParams.get('repo') || DEFAULT_REPO
if (!ALLOWED_REPOS.includes(repo)) {
return NextResponse.json({ error: 'Repo not allowed' }, { status: 403 })
}
const token = process.env.FORGEJO_TOKEN
if (!token) {
@@ -15,7 +20,7 @@ export async function GET() {
try {
const response = await fetch(
`${FORGEJO_URL}/api/v1/repos/${REPO}/actions/runs?limit=1`,
`${FORGEJO_URL}/api/v1/repos/${repo}/actions/runs?limit=1`,
{
headers: {
Authorization: `token ${token}`,
@@ -42,6 +47,7 @@ export async function GET() {
return NextResponse.json({
status: latestRun.status,
conclusion: latestRun.conclusion,
sha: latestRun.head_sha,
title: latestRun.display_title || latestRun.head_branch,
branch: latestRun.head_branch,
url: latestRun.html_url,
+50 -1
View File
@@ -1,8 +1,52 @@
'use client'
import { motion } from 'framer-motion'
import { useState, useEffect } from 'react'
import { GitBranch, CheckCircle, XCircle, Loader2 } from 'lucide-react'
import { useLanguage } from '@/lib/LanguageContext'
interface RepoCI {
sha: string
status: string
url: string
}
function CIBadge({ repo, forgejoUrl }: { repo: string; forgejoUrl: string }) {
const [ci, setCI] = useState<RepoCI | null>(null)
useEffect(() => {
fetch(`/api/ci-status?repo=${repo}`)
.then(r => r.json())
.then(data => setCI({
sha: data.sha?.substring(0, 7) || '',
status: data.conclusion || data.status || 'unknown',
url: data.url || `${forgejoUrl}/actions`,
}))
.catch(() => null)
}, [repo, forgejoUrl])
if (!ci || !ci.sha) return null
const icon = ci.status === 'success'
? <CheckCircle size={12} className="text-green-500" />
: ci.status === 'failure'
? <XCircle size={12} className="text-red-500" />
: <Loader2 size={12} className="animate-spin text-yellow-500" />
return (
<a
href={`${forgejoUrl}/commit/${ci.sha}`}
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-1.5 px-2 py-1 rounded-full bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 hover:border-blue-400 dark:hover:border-blue-600 transition-colors"
>
<GitBranch size={10} className="text-gray-400" />
<span className="text-xs font-mono text-gray-600 dark:text-gray-300">{ci.sha}</span>
{icon}
</a>
)
}
const colors = [
'from-green-500 to-green-600',
'from-red-500 to-red-600',
@@ -93,9 +137,14 @@ export function ExperienceTimeline() {
{item.role}
</p>
</div>
<span className="text-xs font-mono text-gray-500 dark:text-gray-400 whitespace-nowrap ml-4">
<div className="flex flex-col items-end gap-1 ml-4">
<span className="text-xs font-mono text-gray-500 dark:text-gray-400 whitespace-nowrap">
{item.period}
</span>
{index === 0 && (
<CIBadge repo="rock/homelab" forgejoUrl="https://forgejo.riotpiao.com/rock/homelab" />
)}
</div>
</div>
<p className="text-sm text-gray-700 dark:text-gray-300 mb-3">