Skip to content

Commit 8f17247

Browse files
nzakasmdjermanovic
andauthored
chore: Set up automatic updating of README (#16717)
* chore: Set up automatic updating of README * Update tools/update-readme.js Co-authored-by: Milos Djermanovic <[email protected]> Co-authored-by: Milos Djermanovic <[email protected]>
1 parent 4e4049c commit 8f17247

5 files changed

Lines changed: 127 additions & 34 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Data Fetch
2+
3+
on:
4+
schedule:
5+
- cron: "0 8 * * *" # Every day at 1am PDT
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out repo
12+
uses: actions/checkout@v3
13+
with:
14+
token: ${{ secrets.WORKFLOW_PUSH_BOT_TOKEN }}
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v3
18+
19+
- name: Install npm packages
20+
run: npm install
21+
22+
- name: Update README with latest team and sponsor data
23+
run: npm run build:readme
24+
25+
- name: Setup Git
26+
run: |
27+
git config user.name "GitHub Actions Bot"
28+
git config user.email "<[email protected]>"
29+
30+
- name: Save updated files
31+
run: |
32+
chmod +x ./tools/commit-readme.sh
33+
./tools/commit-readme.sh

README.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,6 @@ Nitin Kumar
245245
The people who review and fix bugs and help triage issues.
246246

247247
<table><tbody><tr><td align="center" valign="top" width="11%">
248-
<a href="https://github.com/brettz9">
249-
<img src="https://github.com/brettz9.png?s=75" width="75" height="75"><br />
250-
Brett Zamir
251-
</a>
252-
</td><td align="center" valign="top" width="11%">
253248
<a href="https://github.com/bmish">
254249
<img src="https://github.com/bmish.png?s=75" width="75" height="75"><br />
255250
Bryan Mishkin
@@ -260,14 +255,25 @@ Bryan Mishkin
260255
Sara Soueidan
261256
</a>
262257
</td><td align="center" valign="top" width="11%">
263-
<a href="https://github.com/g-plane">
264-
<img src="https://github.com/g-plane.png?s=75" width="75" height="75"><br />
265-
Pig Fang
258+
<a href="https://github.com/yeonjuan">
259+
<img src="https://github.com/yeonjuan.png?s=75" width="75" height="75"><br />
260+
YeonJuan
261+
</a>
262+
</td></tr></tbody></table>
263+
264+
### Website Team
265+
266+
Team members who focus specifically on eslint.org
267+
268+
<table><tbody><tr><td align="center" valign="top" width="11%">
269+
<a href="https://github.com/bmish">
270+
<img src="https://github.com/bmish.png?s=75" width="75" height="75"><br />
271+
Bryan Mishkin
266272
</a>
267273
</td><td align="center" valign="top" width="11%">
268-
<a href="https://github.com/anikethsaha">
269-
<img src="https://github.com/anikethsaha.png?s=75" width="75" height="75"><br />
270-
Anix
274+
<a href="https://github.com/SaraSoueidan">
275+
<img src="https://github.com/SaraSoueidan.png?s=75" width="75" height="75"><br />
276+
Sara Soueidan
271277
</a>
272278
</td><td align="center" valign="top" width="11%">
273279
<a href="https://github.com/yeonjuan">
@@ -285,10 +291,10 @@ The following companies, organizations, and individuals support ESLint's ongoing
285291
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
286292
<!--sponsorsstart-->
287293
<h3>Platinum Sponsors</h3>
288-
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
289-
<p><a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="96"></a></p><h3>Silver Sponsors</h3>
290-
<p><a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a></p><h3>Bronze Sponsors</h3>
291-
<p><a href="https://launchdarkly.com"><img src="https://images.opencollective.com/launchdarkly/574bb9e/logo.png" alt="launchdarkly" height="32"></a> <a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a></p>
294+
<p><a href="#"><img src="https://images.opencollective.com/2021-frameworks-fund/logo.png" alt="Chrome Frameworks Fund" height="undefined"></a> <a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
295+
<p><a href="https://ridicorp.com/career/"><img src="https://images.opencollective.com/ridi-corporation/175dcf3/logo.png" alt="RIDI" height="96"></a> <a href="https://engineering.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a></p><h3>Silver Sponsors</h3>
296+
<p><a href="https://sentry.io"><img src="https://avatars.githubusercontent.com/u/1396951?v=4" alt="Sentry" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a></p><h3>Bronze Sponsors</h3>
297+
<p><a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://quickbookstoolhub.com"><img src="https://avatars.githubusercontent.com/u/95090305?u=e5bc398ef775c9ed19f955c675cdc1fb6abf01df&v=4" alt="QuickBooks Tool hub" height="32"></a></p>
292298
<!--sponsorsend-->
293299

294300
## Technology Sponsors

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"build:docs:update-links": "node tools/fetch-docs-links.js",
1717
"build:site": "node Makefile.js gensite",
1818
"build:webpack": "node Makefile.js webpack",
19+
"build:readme": "node tools/update-readme.js",
1920
"lint": "node Makefile.js lint",
2021
"lint:docs:js": "node Makefile.js lintDocsJS",
2122
"lint:fix": "node Makefile.js lint -- fix",

tools/commit-readme.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
#------------------------------------------------------------------------------
4+
# Commits the data files if any have changed
5+
#------------------------------------------------------------------------------
6+
7+
if [ -z "$(git status --porcelain)" ]; then
8+
echo "Data did not change."
9+
else
10+
echo "Data changed!"
11+
12+
# commit the result
13+
git add README.md
14+
git commit -m "docs: Update README"
15+
16+
# push back to source control
17+
git push origin HEAD
18+
fi

tools/update-readme.js

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@
1313
// Requirements
1414
//-----------------------------------------------------------------------------
1515

16-
const path = require("path");
1716
const fs = require("fs");
1817
const { stripIndents } = require("common-tags");
1918
const ejs = require("ejs");
19+
const got = require("got");
2020

2121
//-----------------------------------------------------------------------------
2222
// Data
2323
//-----------------------------------------------------------------------------
2424

25-
const README_FILE_PATH = path.resolve(__dirname, "../README.md");
26-
const WEBSITE_DATA_PATH = path.resolve(__dirname, "../../website/_data");
25+
const SPONSORS_URL = "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/sponsors.json";
26+
const TEAM_URL = "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/team.json";
27+
const README_FILE_PATH = "./README.md";
2728

28-
const team = JSON.parse(fs.readFileSync(path.join(WEBSITE_DATA_PATH, "team.json")));
29-
const allSponsors = JSON.parse(fs.readFileSync(path.join(WEBSITE_DATA_PATH, "sponsors.json")));
3029
const readme = fs.readFileSync(README_FILE_PATH, "utf8");
3130

3231
const heights = {
@@ -35,13 +34,31 @@ const heights = {
3534
bronze: 32
3635
};
3736

38-
// remove backers from sponsors list - not shown on readme
39-
delete allSponsors.backers;
40-
4137
//-----------------------------------------------------------------------------
4238
// Helpers
4339
//-----------------------------------------------------------------------------
4440

41+
/**
42+
* Fetches the latest sponsors data from the website.
43+
* @returns {Object} The sponsors data object.
44+
*/
45+
async function fetchSponsorsData() {
46+
const data = await got(SPONSORS_URL).json();
47+
48+
// remove backers from sponsors list - not shown on readme
49+
delete data.backers;
50+
51+
return data;
52+
}
53+
54+
/**
55+
* Fetches the latest team data from the website.
56+
* @returns {Object} The sponsors data object.
57+
*/
58+
async function fetchTeamData() {
59+
return got(TEAM_URL).json();
60+
}
61+
4562
/**
4663
* Formats an array of team members for inclusion in the readme.
4764
* @param {Array} members The array of members to format.
@@ -74,7 +91,7 @@ function formatSponsors(sponsors) {
7491
${
7592
nonEmptySponsors.map(tier => `<h3>${tier[0].toUpperCase()}${tier.slice(1)} Sponsors</h3>
7693
<p>${
77-
sponsors[tier].map(sponsor => `<a href="${sponsor.url}"><img src="${sponsor.image}" alt="${sponsor.name}" height="${heights[tier]}"></a>`).join(" ")
94+
sponsors[tier].map(sponsor => `<a href="${sponsor.url || "#"}"><img src="${sponsor.image}" alt="${sponsor.name}" height="${heights[tier]}"></a>`).join(" ")
7895
}</p>`).join("")
7996
}
8097
<!--sponsorsend-->`;
@@ -111,20 +128,38 @@ const HTML_TEMPLATE = stripIndents`
111128
112129
<%- formatTeamMembers(team.committers) %>
113130
131+
<% } %>
132+
133+
<% if (team.website.length > 0) { %>
134+
### Website Team
135+
136+
Team members who focus specifically on eslint.org
137+
138+
<%- formatTeamMembers(team.website) %>
139+
114140
<% } %>
115141
<!--teamend-->
116142
`;
117143

118-
// replace all of the section
119-
let newReadme = readme.replace(/<!--teamstart-->[\w\W]*?<!--teamend-->/u, ejs.render(HTML_TEMPLATE, {
120-
team,
121-
formatTeamMembers
122-
}));
144+
(async () => {
145+
146+
const [allSponsors, team] = await Promise.all([
147+
fetchSponsorsData(),
148+
fetchTeamData()
149+
]);
150+
151+
// replace all of the section
152+
let newReadme = readme.replace(/<!--teamstart-->[\w\W]*?<!--teamend-->/u, ejs.render(HTML_TEMPLATE, {
153+
team,
154+
formatTeamMembers
155+
}));
156+
157+
newReadme = newReadme.replace(/<!--sponsorsstart-->[\w\W]*?<!--sponsorsend-->/u, formatSponsors(allSponsors));
123158

124-
newReadme = newReadme.replace(/<!--sponsorsstart-->[\w\W]*?<!--sponsorsend-->/u, formatSponsors(allSponsors));
159+
// replace multiple consecutive blank lines with just one blank line
160+
newReadme = newReadme.replace(/(?<=^|\n)\n{2,}/gu, "\n");
125161

126-
// replace multiple consecutive blank lines with just one blank line
127-
newReadme = newReadme.replace(/(?<=^|\n)\n{2,}/gu, "\n");
162+
// output to the file
163+
fs.writeFileSync(README_FILE_PATH, newReadme, "utf8");
128164

129-
// output to the file
130-
fs.writeFileSync(README_FILE_PATH, newReadme, "utf8");
165+
})();

0 commit comments

Comments
 (0)