mirror of
https://github.com/MunGell/awesome-for-beginners.git
synced 2026-01-23 20:08:09 -08:00
Switch authoring to JSON file and add build/verification actions
This commit is contained in:
17
.github/pull_request_template.md
vendored
17
.github/pull_request_template.md
vendored
@@ -1,17 +0,0 @@
|
||||
Please complete the following checklist if your PR is adding new link to the list:
|
||||
|
||||
- [ ] I've read [contributing guidelines](https://github.com/MunGell/awesome-for-beginners/blob/master/CONTRIBUTING.md)
|
||||
- [ ] This PR does not introduce duplicates to the list
|
||||
- [ ] The link is added at the bottom of the list category
|
||||
- [ ] Suggested repository is maintained, have active community, is able to mentor new contributors and have issues with the suggested label
|
||||
- [ ] The link I add follows the suggested pattern:
|
||||
|
||||
```
|
||||
- [Repository Name](link-to-repository-label) _(label: beginner-friendly-label-in-the-repository)_ <br> Description
|
||||
```
|
||||
|
||||
Example link formatting:
|
||||
|
||||
```
|
||||
- [awesome-for-beginners](https://github.com/MunGell/awesome-for-beginners/labels/good-first-contribution) _(label: good-first-contribution)_ <br> A list of awesome beginners-friendly projects.
|
||||
```
|
||||
87
.github/scripts/build.js
vendored
Normal file
87
.github/scripts/build.js
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
const fs = require('fs');
|
||||
const data = require('../../data.json');
|
||||
|
||||
const TPL_FILE = './.github/tpl.md';
|
||||
const TARGET = './README.md';
|
||||
|
||||
const tpl = getTemplate(TPL_FILE);
|
||||
|
||||
const categories = {};
|
||||
|
||||
data.repositories.sort((a, b) => {
|
||||
const nameA = a.name.toUpperCase();
|
||||
const nameB = b.name.toUpperCase();
|
||||
if (nameA < nameB) {
|
||||
return -1;
|
||||
}
|
||||
if (nameA > nameB) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}).forEach(repo =>
|
||||
repo.technologies.forEach(tech => {
|
||||
if (!categories.hasOwnProperty(tech)) {
|
||||
categories[tech] = [];
|
||||
}
|
||||
categories[tech].push(repo);
|
||||
}))
|
||||
|
||||
const sortedCategories = Object.fromEntries(Object.entries(categories).sort((a, b) => {
|
||||
const nameA = a[0].toUpperCase();
|
||||
const nameB = b[0].toUpperCase();
|
||||
if (nameA < nameB) {
|
||||
return -1;
|
||||
}
|
||||
if (nameA > nameB) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}));
|
||||
|
||||
const toc = Object.keys(sortedCategories)
|
||||
.map(t => `- [${t}](#${data.technologies[t] || t.toLowerCase()})`)
|
||||
.join('\n');
|
||||
|
||||
const content = Object.keys(sortedCategories)
|
||||
.map(category => {
|
||||
const repos = sortedCategories[category].map(repo => `- [${repo.name}](${repo.link}) _(label: ${repo.label || 'n/a'})_ <br> ${repo.description}`).join('\n')
|
||||
return `## ${category}\n\n${repos}\n`
|
||||
}).join('\n');
|
||||
|
||||
const sponsorList = data.sponsors.map(sponsor => `<td align="center"><a href="${sponsor.link}"><img src="${sponsor.image}" width="60px;" alt=""/><br/><sub><b>${sponsor.name}</b></sub></a></td>`)
|
||||
const sponsorRows = Math.ceil(sponsorList.length / 6);
|
||||
|
||||
let sponsors = '';
|
||||
|
||||
for (let i = 1; i <= sponsorRows; i++) {
|
||||
sponsors += '<tr>';
|
||||
for(let j = 0; j < 6; j++) {
|
||||
if (sponsorList.length > i*j) {
|
||||
sponsors += sponsorList[i*j];
|
||||
} else if (sponsorRows > 1) {
|
||||
sponsors += '<td></td>'
|
||||
}
|
||||
}
|
||||
sponsors += '</tr>';
|
||||
}
|
||||
|
||||
sponsors = `<table>${sponsors}</table>`
|
||||
|
||||
saveFile(TARGET, render(tpl, { toc, content, sponsors }));
|
||||
|
||||
function getTemplate(file) {
|
||||
return fs.readFileSync(file).toString();
|
||||
}
|
||||
|
||||
function saveFile(file, contents) {
|
||||
return fs.writeFileSync(file, contents);
|
||||
}
|
||||
|
||||
function render(template, variables) {
|
||||
Object
|
||||
.entries(variables)
|
||||
.forEach(([key, value]) => {
|
||||
template = template.replace(new RegExp(`<% ${key} %>`, 'g'), value);
|
||||
});
|
||||
return template;
|
||||
}
|
||||
3
.github/stale.yml
vendored
3
.github/stale.yml
vendored
@@ -1,3 +0,0 @@
|
||||
daysUntilStale: 5
|
||||
daysUntilClose: 1
|
||||
closeComment: false
|
||||
31
.github/tpl.md
vendored
Normal file
31
.github/tpl.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
[](https://www.doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=awesomeforbeginners&utm_source=github)
|
||||
|
||||
# Awesome First PR Opportunities [](https://github.com/sindresorhus/awesome)
|
||||
|
||||
This list of awesome beginner-friendly projects is sponsored by [Doppler](https://www.doppler.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=awesomeforbeginners&utm_source=github) – convenient and secure way to manage all your environment variables.
|
||||
|
||||
Inspired by [First Timers Only](https://kentcdodds.com/blog/first-timers-only) blog post.
|
||||
|
||||
If you are a maintainer of open-source projects, add the label `first-timers-only` (or similar) to your project and list it here so that people can find it.
|
||||
|
||||
If you are not a programmer but would like to contribute, check out the [Awesome for non-programmers](https://github.com/szabgab/awesome-for-non-programmers) list.
|
||||
|
||||
## Table of Contents:
|
||||
|
||||
<% toc %>
|
||||
|
||||
<% content %>
|
||||
|
||||
## Contribute
|
||||
|
||||
Contributions are welcome! See the [contributing guidelines](CONTRIBUTING.md).
|
||||
|
||||
## Thanks to GitHub Sponsors
|
||||
|
||||
<% sponsors %>
|
||||
|
||||
## License
|
||||
|
||||
[](http://creativecommons.org/publicdomain/zero/1.0/)
|
||||
|
||||
To the extent possible under law, the author has waived all copyrights and related or neighboring rights to this work.
|
||||
26
.github/workflows/build.yml
vendored
Normal file
26
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
paths:
|
||||
- 'data.json'
|
||||
- '.github/tpl.md'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "16.x"
|
||||
- name: Build
|
||||
run: node .github/scripts/build.js
|
||||
- name: Commit
|
||||
run: |
|
||||
git config --global user.name 'Shmavon Gazanchyan'
|
||||
git config --global user.email 'MunGell@users.noreply.github.com'
|
||||
git commit -am "Update README.md"
|
||||
git push
|
||||
38
.github/workflows/invalid.yml
vendored
Normal file
38
.github/workflows/invalid.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
name: Check on Invalid PR
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
- 'data.json'
|
||||
- 'CONTRIBUTING.md'
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: 'This PR is not valid. Please read [contributing guidelines](https://github.com/MunGell/awesome-for-beginners/CONTRIBUTING.md).'
|
||||
});
|
||||
if (context.payload.pull_request.labels.indexOf('Invalid') === -1) {
|
||||
await github.rest.issues.addLabels({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
labels: ['Invalid']
|
||||
});
|
||||
}
|
||||
await github.rest.pulls.update({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.issue.number,
|
||||
state: 'closed'
|
||||
});
|
||||
Reference in New Issue
Block a user