-
Notifications
You must be signed in to change notification settings - Fork 118
Automated README.md generator & individual item files #92
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
Open
CamKem
wants to merge
48
commits into
timb-103:main
Choose a base branch
from
CamKem:read-me-generator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
4934487
CSJ script to build the README.md automatically from the files that a…
42138ee
Added the "gray-matter" yaml parsing dependency.
13f519e
Added the partials needed for building the README.md
9b5883f
Removed comments and added the link in contents for the contribution …
d72641a
Added interview links
b98267e
Parsed the README.md with a script to automatically generate the md f…
a01e7aa
Updated with the data parsed from the original README.md
5a85b6f
removed original README.md to add generated one
5f45ec8
Updated with parsed README.md data
8d1a6af
Updated sections.md to reflect the correct category names, for when t…
fc4d1f1
Fixed yaml syntax so it builds correctly.
fb67e1e
Created the example.md file so people know how to add their link to t…
2f8e6d9
Added the introduction.md for building
03759bc
Allowed for corrected building based on category
35974bf
Updated pallyy.md fully to show what details could be added
63bf290
Fixed the inconsistency with the ampersands/and in the contents vs he…
070efb6
Build new README.md using the automated script
6dd2547
Added workflow for github action to generate the README.md each time …
feb0a4a
Added solid.md to test the github action to automatically build the R…
4634e7f
Merge pull request #1 from CamKem/read-me-generator-tester
CamKem 1edf760
Revert "Added solid.md to test the github action for auto building RE…
CamKem 8e480f4
Merge pull request #2 from CamKem/revert-1-read-me-generator-tester
CamKem 45398d8
changed working directory in the GitHub action.
a7a0dce
added solid.md to test the github action on merge
86d2229
Merge pull request #3 from CamKem/new-item-built-test
CamKem 6eef097
Revert "Testing the github action"
CamKem 84add72
Merge pull request #4 from CamKem/revert-3-new-item-built-test
CamKem a4afd7a
Corrected mistake in the working directory
1712bb6
Added solid.md for final test of the github action
f67e424
Merge pull request #5 from CamKem/read-me-generator-final-test
CamKem 244987b
changed again
40d668c
changed again
59b919e
Merge pull request #6 from CamKem/read-me-generator-solid
CamKem 479d43d
Update README.md
actions-user d898362
Fixed ampersands causing issues with contents links targeting categor…
62ec32b
Added function to sanitise the links being built to prevent any broke…
a9b513e
remove the testing branch from the targeted branches in the GH Action…
85ed60c
parsed items from merged PRs to build md files & rebuilt README.md wi…
c1b5103
Updated contributing.md to reflect the new instructions for adding an…
c0021c1
Updated the example.md to give a better example of what should be add…
ef73774
Added "website builders" section recently merged
45a180e
Built new items recently merged & rebuilt the README.md
9ff5c63
Build publer.md item file & rebuilt README.md to stay in sync
584cc23
Added hosting coolify.md & hetzner.md, that I missed & rebuilt the RE…
d9d0a00
Correct url typo for the added items
afcc6ed
Rebuild README.md with url typo fixed.
c25e4d9
parsed-items using code for simple-analytics interview & rebuild READ…
8447643
Commit merged commits from upstream remote origin & updated files to …
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Build README.md | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| build: | ||
| if: github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
| working-directory: ./.website | ||
|
|
||
| - name: Build README | ||
| run: npm run build-readme | ||
| working-directory: ./.website | ||
|
|
||
| - name: Commit and push changes | ||
| run: | | ||
| git diff | ||
| git config --local user.email "action@github.com" | ||
| git config --local user.name "GitHub Action" | ||
| git commit -am "Update README.md" || echo "No changes to commit" | ||
| git push |
|
CamKem marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| // This script is used to build the README file by combining the header, sections, and contribute files with the items files. | ||
|
|
||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const matter = require('gray-matter'); | ||
|
|
||
| // Function to sanitize names for use in links | ||
| function sanitizeName(name) { | ||
| name = name.trim() | ||
| .toLowerCase() | ||
| .replace(/ /g, '-') | ||
| .replace(/&/g, 'and') | ||
| .replace(/[^\w-]+/g, ''); | ||
| return encodeURIComponent(name) | ||
| } | ||
|
|
||
| // Start the content with the header | ||
| let content = fs.readFileSync(path.join(__dirname, '../partials/header.md'), 'utf8'); | ||
|
|
||
| // Read the sections file | ||
| const sectionsFilePath = path.join(__dirname, '../partials/sections.md'); | ||
| const sectionsFileContent = fs.readFileSync(sectionsFilePath, 'utf-8'); | ||
| const {sections, categories} = matter(sectionsFileContent).data; | ||
|
|
||
| // Add the table of contents | ||
| content += '\n## Table of Contents\n'; | ||
| for (const section of sections) { | ||
| content += '- [' + section.name + '](#' + sanitizeName(section.name) + ')\n'; | ||
| if (section.name === 'Tools') { | ||
| for (const category of categories) { | ||
| content += ' - [' + category.name + '](#' + sanitizeName(category.name) + ')\n'; | ||
| } | ||
| } | ||
| } | ||
| // Add the contribute link to the table of contents | ||
| content += '- [Contribute](#contribute)\n'; | ||
| content += '\n'; | ||
|
|
||
| // Add the sections to the content | ||
| for (const section of sections) { | ||
| content += '## ' + section.name + '\n'; | ||
| if (section.description) { | ||
| content += section.description + '\n'; | ||
| } | ||
|
|
||
| // Add the items for this section to the content | ||
| const itemsDir = path.join(__dirname, '../items'); | ||
| const sectionDirs = fs.readdirSync(itemsDir); | ||
| let items = []; | ||
| for (const sectionDir of sectionDirs) { | ||
| const sectionDirPath = path.join(itemsDir, sectionDir); | ||
| if (fs.statSync(sectionDirPath).isDirectory()) { | ||
| const itemFiles = fs.readdirSync(sectionDirPath); | ||
| for (const itemFile of itemFiles) { | ||
| const itemFilePath = path.join(sectionDirPath, itemFile); | ||
| const itemFileContent = fs.readFileSync(itemFilePath, 'utf-8'); | ||
| const item = matter(itemFileContent).data; | ||
|
|
||
| // Check if the item's section matches the current section | ||
| if (item.section === section.name) { | ||
| // Check if the item's category is valid or if it doesn't have a category | ||
| if (!item.category || categories.find(category => category.name === item.category)) { | ||
| items.push(item); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Group the items by category if the section is Tools | ||
| const itemsByCategory = items.reduce((groups, item) => { | ||
| if (item.category) { | ||
| if (!groups[item.category]) { | ||
| groups[item.category] = []; | ||
| } | ||
| groups[item.category].push(item); | ||
| } | ||
| return groups; | ||
| }, {}); | ||
|
|
||
| // Add the items to the content | ||
| if (section.name === 'Tools') { | ||
| for (const category of categories) { | ||
| content += '### ' + category.name + '\n'; | ||
| if (category.description) { | ||
| // Uncomment this line to add the category description to the content | ||
| //content += category.description + '\n'; | ||
| } | ||
| if (itemsByCategory[category.name]) { | ||
| itemsByCategory[category.name].sort((a, b) => { | ||
| if (a.order && b.order) { | ||
| return a.order - b.order; | ||
| } else { | ||
| return a.name.localeCompare(b.name); | ||
| } | ||
| }); | ||
| for (const item of itemsByCategory[category.name]) { | ||
| content += '- [' + item.name + '](' + item.link + ') - ' + item.description + '\n'; | ||
| } | ||
| } | ||
| content += '\n'; | ||
| } | ||
| } else { | ||
|
|
||
| // Sort the items by order if it exists, otherwise by name | ||
| items.sort((a, b) => { | ||
| if (a.order && b.order) { | ||
| return a.order - b.order; | ||
| } else { | ||
| return a.name.localeCompare(b.name); | ||
| } | ||
| }); | ||
|
|
||
| // Add the items to the content | ||
| for (const item of items) { | ||
| content += '- [' + item.name + '](' + item.link + ') - ' + item.description + '\n'; | ||
| } | ||
|
|
||
| content += '\n'; | ||
|
|
||
| } | ||
|
|
||
| } | ||
|
|
||
| // Add the contribution section | ||
| const contributePath = path.join(__dirname, '../partials/contribute.md'); | ||
| const contributeContent = fs.readFileSync(contributePath, 'utf-8'); | ||
| content += contributeContent; | ||
|
|
||
| // Write the combined content to the README file | ||
| fs.writeFileSync(path.join(__dirname, '../README.md'), content); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
|
CamKem marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.