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,55 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import matter from 'gray-matter'
|
||||
|
||||
const KNIEPUNKT_DIR = path.join(process.cwd(), 'content', 'kniepunkt')
|
||||
|
||||
// 1. Delete the intro for 040
|
||||
const papstIntro = path.join(KNIEPUNKT_DIR, '2026-05-30-der-papst-scheint-den-kniepunkt-auch-zu-lesen-darum-geht-es-heute-und-darum-da.md')
|
||||
if (fs.existsSync(papstIntro)) {
|
||||
fs.unlinkSync(papstIntro)
|
||||
console.log('Deleted Papst intro')
|
||||
}
|
||||
|
||||
// 2. Merge "Der neue Kniepunkt ist da" into 029
|
||||
const kniepunktIntro = path.join(KNIEPUNKT_DIR, '2026-03-14-der-neue-kniepunkt-ist-da.md')
|
||||
const k29Path = path.join(KNIEPUNKT_DIR, '029-ki-nudelsuppe.md')
|
||||
if (fs.existsSync(kniepunktIntro) && fs.existsSync(k29Path)) {
|
||||
const intro = matter(fs.readFileSync(kniepunktIntro, 'utf8'))
|
||||
let k29 = matter(fs.readFileSync(k29Path, 'utf8'))
|
||||
if (!k29.content.includes(intro.content.trim())) {
|
||||
k29.content = `> ${intro.content.trim()}\n\n---\n\n${k29.content}`
|
||||
fs.writeFileSync(k29Path, matter.stringify(k29.content, k29.data))
|
||||
console.log('Merged intro into 029')
|
||||
}
|
||||
fs.unlinkSync(kniepunktIntro)
|
||||
console.log('Deleted Kniepunkt 029 intro')
|
||||
}
|
||||
|
||||
// 3. Rename all Kniepunkt titles to "0[XX]: [Title]"
|
||||
const allFiles = fs.readdirSync(KNIEPUNKT_DIR).filter(f => f.match(/^\d{3}-.*\.md$/))
|
||||
|
||||
allFiles.forEach(file => {
|
||||
const numMatch = file.match(/^(\d{3})-/)
|
||||
if (!numMatch) return
|
||||
const numStr = numMatch[1] // e.g. "012"
|
||||
|
||||
const p = path.join(KNIEPUNKT_DIR, file)
|
||||
let data = matter(fs.readFileSync(p, 'utf8'))
|
||||
|
||||
let currentTitle = data.data.title || ''
|
||||
|
||||
// Clean up current title, remove existing Kniepunkt prefix if any
|
||||
currentTitle = currentTitle.replace(/^Kniepunkt\s*\d+\s*[:-]?\s*/i, '')
|
||||
currentTitle = currentTitle.replace(/^0\d{2}\s*[:-]?\s*/, '')
|
||||
currentTitle = currentTitle.trim()
|
||||
|
||||
const newTitle = `${numStr}: ${currentTitle}`
|
||||
|
||||
if (data.data.title !== newTitle) {
|
||||
data.data.title = newTitle
|
||||
fs.writeFileSync(p, matter.stringify(data.content, data.data))
|
||||
console.log('Renamed title for', file, 'to', newTitle)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user