The code for my personal website, powered by Jekyll. arthr.me
jekyll-site personal-website
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

removes unused workflow

authored by

Arthur Freitas and committed by
GitHub
ebae4f77 4d5168ab

-92
-92
.github/workflows/email-to-post.yml
··· 1 - name: Issue to Jekyll Post 2 - 3 - on: 4 - issues: 5 - types: [opened] 6 - 7 - jobs: 8 - create-post: 9 - runs-on: ubuntu-latest 10 - permissions: 11 - contents: write 12 - issues: write 13 - 14 - steps: 15 - - uses: actions/checkout@v4 16 - 17 - - name: Process Issue to Post 18 - id: process 19 - uses: actions/github-script@v7 20 - with: 21 - script: | 22 - const { execSync } = require('child_process'); 23 - const fs = require('fs'); 24 - const issue = context.payload.issue; 25 - const title = issue.title; 26 - const body = issue.body; 27 - 28 - let tags = []; 29 - const tagsMatch = body.match(/Tags:(.+)$/im); 30 - if (tagsMatch) { 31 - tags = tagsMatch[1].split(',').map(tag => tag.trim()); 32 - } 33 - 34 - let content = body.replace(/Tags:(.+)$/im, '').trim(); 35 - 36 - const imageRegex = /!\[([^\]]*)\]\(data:image\/[^;]+;base64,([^)]+)\)/g; 37 - const images = []; 38 - let match; 39 - 40 - while ((match = imageRegex.exec(content)) !== null) { 41 - const alt = match[1]; 42 - const base64 = match[2]; 43 - const filename = `${Date.now()}-${images.length}.png`; 44 - 45 - const buffer = Buffer.from(base64, 'base64'); 46 - fs.mkdirSync('uploads', { recursive: true }); 47 - fs.writeFileSync(`uploads/${filename}`, buffer); 48 - 49 - content = content.replace(match[0], `![${alt}](/uploads/${filename})`); 50 - images.push(filename); 51 - } 52 - 53 - const date = new Date(); 54 - const slug = title 55 - .toLowerCase() 56 - .replace(/[^\w\s-]/g, '') 57 - .replace(/\s+/g, '-'); 58 - const filename = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}-${slug}.md`; 59 - 60 - const frontMatter = [ 61 - '---', 62 - `title: "${title}"`, 63 - `date: ${date.toISOString()}`, 64 - 'layout: post', 65 - 'tags:', 66 - ...tags.map(tag => ` - ${tag}`), 67 - '---', 68 - '', 69 - content 70 - ].join('\n'); 71 - 72 - const path = `_posts/${filename}`; 73 - fs.writeFileSync(path, frontMatter); 74 - 75 - execSync('git config --global user.email "github-actions[bot]@users.noreply.github.com"'); 76 - execSync('git config --global user.name "github-actions[bot]"'); 77 - execSync('git add .'); 78 - execSync(`git commit -m "Add post: ${title}"`); 79 - execSync('git push'); 80 - 81 - await github.rest.issues.createComment({ 82 - owner: context.repo.owner, 83 - repo: context.repo.repo, 84 - issue_number: issue.number, 85 - body: `Post criado em \`${path}\`` 86 - }); 87 - await github.rest.issues.update({ 88 - owner: context.repo.owner, 89 - repo: context.repo.repo, 90 - issue_number: issue.number, 91 - state: 'closed' 92 - });