feat: add CI status badge with commit SHA on homelab experience card
Build & Push Portfolio Image / build-push (push) Successful in 4m8s
Build & Push Portfolio Image / build-push (push) Successful in 4m8s
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user