Skip to content

Commit

Permalink
Feat: Convert yml to md
Browse files Browse the repository at this point in the history
  • Loading branch information
currenjin committed Jan 25, 2024
1 parent dfcce6b commit 78520fc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/convert-yml-to-markdown.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: Convert YAML to Markdown
name: Update README

on:
push:
branches:
- develop-yml

jobs:
convert:
update-readme:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Install Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install YAML to Markdown Converter
run: npm install -g yaml-to-md
- name: Install Dependencies
run: npm install

- name: Convert YAML to Markdown
run: yaml-to-md -i sites.yml -o sites.md
- name: Run Update Script
run: node convert-yml-to-md.js
19 changes: 19 additions & 0 deletions .github/workflows/convert-yml-to-md.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require('fs');

function generateMarkdown(categories, sites) {
let markdown = '## 문서\n';
categories.forEach(category => {
markdown += `### ${category.text}\n`;
const categorySites = sites.filter(site => site.categories.includes(category.category));
categorySites.forEach(site => {
markdown += `- [${site.name}](${site.link}) - ${site.description}\n`;
});
});
return markdown;
}

const categories = require('./categories.yml');
const sites = require('./sites.yml');

const readmeContent = generateMarkdown(categories, sites);
fs.writeFileSync('README.md', readmeContent);

0 comments on commit 78520fc

Please sign in to comment.