Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to yml (#21) #22

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/convert-yml-to-markdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Update README

on:
push:
branches:
- develop-yml

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

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

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

- name: Install Dependencies
run: npm install js-yaml

- name: Run Update Script
run: node .github/workflows/convert-yml-to-md.js

- name: Commit README.md
run: |
git config --global user.email "[email protected]"
git config --global user.name "currenjin"
git add README.md
git commit -m "<Action> Docs: README.md"
git push origin develop-yml
36 changes: 36 additions & 0 deletions .github/workflows/convert-yml-to-md.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const fs = require('fs');
const yaml = require('js-yaml');

const initContent = `
## 어떤 저장소인가요?
- 개발자가 참고하면 좋은 대표적인 사이트를 모아놓은 북마크 저장소입니다. 한 분 한 분에게 도움이 되었으면 좋겠습니다. 🙏🏾
- 또한, 참고하면 좋겠다고 생각되는 사이트는 \`Pull Request\` 로 참여해 주시면 감사하겠습니다! -> [How to contribute](./HOW-TO-CONTRIBUTE.md)

## 기여자
[![author](https://img.shields.io/badge/author-currenjin-green.svg?style=flat-square)](https://currenjin.github.io/resume)

<a href="https://github.com/currenjin/site-for-developers/graphs/contributors"><img src="https://opencollective.com/site-for-developers/contributors.svg?width=720"></a>

## 북마크
`;

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

const categoriesContent = fs.readFileSync('./categories.yml', 'utf-8');
const categories = yaml.load(categoriesContent);

const sitesContent = fs.readFileSync('./sites.yml', 'utf-8');
const sites = yaml.load(sitesContent);

const readmeContent = generateMarkdown(categories, sites);
fs.writeFileSync('./README.md', readmeContent);
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
.DS_Store
node_modules
website
android
Loading