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:
@@ -12,9 +12,9 @@ import { readFileSync, readdirSync, writeFileSync, mkdirSync, existsSync } from
|
||||
import { join, basename } from 'path'
|
||||
|
||||
// --- Configuration ---
|
||||
const EXPORT_DIR = join(process.cwd(), 'sources', 'Complete_LinkedInDataExport_05-31-2026')
|
||||
const EXPORT_DIR = join(process.cwd(), 'sources', 'LinkedInDataExport_07-17-2026')
|
||||
const ARTICLES_DIR = join(EXPORT_DIR, 'Articles', 'Articles')
|
||||
const SHARES_FILE = join(EXPORT_DIR, 'Shares_547037907.csv')
|
||||
const SHARES_FILE = join(EXPORT_DIR, 'Shares.csv')
|
||||
const OUTPUT_KNIEPUNKT = join(process.cwd(), 'andreknie.de', 'content', 'kniepunkt')
|
||||
const OUTPUT_POSTS = join(process.cwd(), 'andreknie.de', 'content', 'posts')
|
||||
|
||||
@@ -246,6 +246,7 @@ function extractArticles() {
|
||||
const files = readdirSync(ARTICLES_DIR).filter(f => f.endsWith('.html'))
|
||||
let kniepunktCount = 0
|
||||
let postCount = 0
|
||||
const articleMap = new Map()
|
||||
|
||||
for (const file of files) {
|
||||
const filepath = join(ARTICLES_DIR, file)
|
||||
@@ -279,6 +280,7 @@ function extractArticles() {
|
||||
const output = `${frontmatter}\n\n${article.body}\n`
|
||||
const outputPath = join(OUTPUT_KNIEPUNKT, `${slug}.md`)
|
||||
writeFileSync(outputPath, output, 'utf-8')
|
||||
if (article.linkedinUrl) articleMap.set(article.linkedinUrl, outputPath)
|
||||
kniepunktCount++
|
||||
} else {
|
||||
// Regular article → post
|
||||
@@ -298,24 +300,32 @@ function extractArticles() {
|
||||
const output = `${frontmatter}\n\n${article.body}\n`
|
||||
const outputPath = join(OUTPUT_POSTS, `${slug}.md`)
|
||||
writeFileSync(outputPath, output, 'utf-8')
|
||||
if (article.linkedinUrl) articleMap.set(article.linkedinUrl, outputPath)
|
||||
postCount++
|
||||
}
|
||||
}
|
||||
|
||||
console.log(` ✅ ${kniepunktCount} Kniepunkt issues → content/kniepunkt/`)
|
||||
console.log(` ✅ ${postCount} articles → content/posts/`)
|
||||
return articleMap
|
||||
}
|
||||
|
||||
function extractShares() {
|
||||
function extractShares(articleMap) {
|
||||
console.log('\n📢 Extracting Shares (Posts)...')
|
||||
ensureDir(OUTPUT_POSTS)
|
||||
ensureDir(OUTPUT_KNIEPUNKT)
|
||||
|
||||
if (!existsSync(SHARES_FILE)) {
|
||||
console.log(` ⏭️ Skipping Shares: File not found at ${SHARES_FILE}`)
|
||||
return
|
||||
}
|
||||
|
||||
const shares = parseSharesCsv(SHARES_FILE)
|
||||
console.log(` 📊 Total shares in export: ${shares.length}`)
|
||||
|
||||
let postCount = 0
|
||||
let kniepunktCount = 0
|
||||
let mergedCount = 0
|
||||
let skipped = 0
|
||||
|
||||
for (const share of shares) {
|
||||
@@ -324,10 +334,38 @@ function extractShares() {
|
||||
continue
|
||||
}
|
||||
|
||||
// Skip reposts of articles (they'll be extracted from Articles/)
|
||||
// Check if this share links to an Article we already extracted
|
||||
if (share.sharedUrl && share.sharedUrl.includes('linkedin.com/pulse/')) {
|
||||
skipped++
|
||||
continue
|
||||
// Find the article by matching the pulse URL
|
||||
// (The article map uses the URL from the HTML, which might match exactly or partially)
|
||||
const matchedArticlePath = articleMap.get(share.sharedUrl) ||
|
||||
Array.from(articleMap.keys()).find(url => url && share.sharedUrl.includes(url) || url.includes(share.sharedUrl))
|
||||
|
||||
if (matchedArticlePath) {
|
||||
// Read the article, append the commentary, and overwrite
|
||||
const fs = await import('fs');
|
||||
const matter = (await import('gray-matter')).default || require('gray-matter'); // Use dynamic import or require
|
||||
// Wait, we are in an ES module environment (import readFileSync from 'fs')
|
||||
// I will just use readFileSync and a simple regex to prepend after frontmatter
|
||||
const raw = readFileSync(matchedArticlePath, 'utf8')
|
||||
const parts = raw.split(/^---$/m)
|
||||
if (parts.length >= 3) {
|
||||
const frontmatter = parts[1]
|
||||
const body = parts.slice(2).join('---')
|
||||
|
||||
// Prepend commentary to body
|
||||
const newBody = share.commentary + '\n\n---\n\n' + body.trim() + '\n'
|
||||
const newRaw = '---\n' + frontmatter.trim() + '\n---\n\n' + newBody
|
||||
|
||||
writeFileSync(matchedArticlePath, newRaw, 'utf8')
|
||||
mergedCount++
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
// Couldn't find matching article, just skip or treat as post
|
||||
skipped++
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
const date = share.date ? share.date.split(' ')[0] : null
|
||||
@@ -413,8 +451,8 @@ if (existsSync(samplePost)) {
|
||||
unlinkSync(samplePost)
|
||||
}
|
||||
|
||||
extractArticles()
|
||||
extractShares()
|
||||
const articleMap = extractArticles()
|
||||
extractShares(articleMap)
|
||||
|
||||
console.log('\n✨ Done! Review the generated files in andreknie.de/content/')
|
||||
console.log(' - Check content/kniepunkt/ for column issues')
|
||||
|
||||
Reference in New Issue
Block a user