ci: migrate GitHub actions to Gitea actions
Deploy CV Site (andreknie.de) / deploy (push) Canceled after 0s
Deploy CV Site (andreknie.de) / deploy (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import matter from 'gray-matter'
|
||||
|
||||
const SRC_DIR = '/home/andre/coden/Kniepunkt/Kniepunkt-Visuals'
|
||||
const DEST_DIR = path.join(process.cwd(), 'public', 'images', 'kniepunkt')
|
||||
const CONTENT_DIR = path.join(process.cwd(), 'content', 'kniepunkt')
|
||||
|
||||
if (!fs.existsSync(DEST_DIR)) {
|
||||
fs.mkdirSync(DEST_DIR, { recursive: true })
|
||||
}
|
||||
|
||||
const images = fs.readdirSync(SRC_DIR).filter(f => f.endsWith('.png'))
|
||||
const mdFiles = fs.readdirSync(CONTENT_DIR).filter(f => f.endsWith('.md'))
|
||||
|
||||
images.forEach(img => {
|
||||
// Extract number from image name
|
||||
const match = img.match(/(\d{1,3})/)
|
||||
if (!match) return
|
||||
|
||||
// Normalize number string to 3 digits (e.g., '1' -> '001', '12' -> '012')
|
||||
const numStr = match[1].padStart(3, '0')
|
||||
|
||||
// Find matching markdown file
|
||||
const mdFile = mdFiles.find(f => f.startsWith(numStr + '-'))
|
||||
if (mdFile) {
|
||||
// Copy image
|
||||
const safeName = `${numStr}-cover.png`
|
||||
fs.copyFileSync(path.join(SRC_DIR, img), path.join(DEST_DIR, safeName))
|
||||
|
||||
// Update frontmatter
|
||||
const mdPath = path.join(CONTENT_DIR, mdFile)
|
||||
const data = matter(fs.readFileSync(mdPath, 'utf8'))
|
||||
data.data.image = `/images/kniepunkt/${safeName}`
|
||||
|
||||
fs.writeFileSync(mdPath, matter.stringify(data.content, data.data))
|
||||
console.log(`Matched and updated: ${numStr}`)
|
||||
} else {
|
||||
console.log(`No markdown file found for image: ${img} (expected prefix ${numStr}-)`)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user