Skip to content
Merged
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
57 changes: 57 additions & 0 deletions .github/workflows/update-readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: update-readme

on:
schedule:
- cron: "0 8 * * *" # Runs every day at 08:00 AM UTC

workflow_dispatch:

workflow_call:
secrets:
workflow_push_bot_token:
required: true
description: Token for the workflow bot to push changes

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

steps:
- name: Check out repo
uses: actions/checkout@v5
with:
token: ${{ secrets.workflow_push_bot_token }}

- name: Set up Node.js
uses: actions/setup-node@v5
with:
node-version: "lts/*"

- name: Copy update-readme script from workflows repository
run: curl --create-dirs -fsSL https://raw.githubusercontent.com/eslint/workflows/main/tools/update-readme.js -o tools/update-readme.js

- name: Update README with latest sponsor data
run: node tools/update-readme.js

- name: Setup Git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<[email protected]>"

- name: Commit README
run: |
# Unmatched patterns are dropped to avoid git errors
shopt -s nullglob

if [ -z "$(git status --porcelain)" ]; then
echo "Data did not change."
else
echo "Data changed!"

# commit the result
git add README.md packages/**/README.md
git commit -m "docs: Update README sponsors"

# push back to source control
git push origin HEAD
fi
7 changes: 7 additions & 0 deletions README.md
Copy link
Member Author

@lumirlumir lumirlumir Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's okay, could this PR include only a ## Sponsors heading for now, so we can verify the update-readme workflow is working correctly in the workflows repository?

Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ This repository is intended exclusively for ESLint repositories. It is tailored
## License

Apache 2.0

<!-- NOTE: This section is autogenerated. Do not manually edit.-->
<!--sponsorsstart-->

## Sponsors

<!--sponsorsend-->
45 changes: 45 additions & 0 deletions tools/update-readme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @fileoverview Script to update the README with sponsors details in all packages.
*
* node tools/update-readme.js
*
* @author 루밀LuMir(lumirlumir)
*/

//-----------------------------------------------------------------------------
// Import
//-----------------------------------------------------------------------------

import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';

//-----------------------------------------------------------------------------
// Data
//-----------------------------------------------------------------------------

const SPONSORS_URL = 'https://raw.githubusercontent.com/eslint/eslint.org/main/includes/sponsors.md';
const PACKAGES_README_FILE_PATHS = existsSync('./packages')
? readdirSync('./packages').map(dir => `./packages/${dir}/README.md`)
: [];
const README_FILE_PATHS = ['./README.md', ...PACKAGES_README_FILE_PATHS];

//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------

const response = await fetch(SPONSORS_URL);
const allSponsors = await response.text();

README_FILE_PATHS.forEach(readmeFilePath => {
const readme = readFileSync(readmeFilePath, 'utf8'); // Read README file

let newReadme = readme.replace(
/<!--sponsorsstart-->[\s\S]*?<!--sponsorsend-->/u,
`<!--sponsorsstart-->\n\n${allSponsors}\n<!--sponsorsend-->`,
);

// replace multiple consecutive blank lines with just one blank line
newReadme = newReadme.replace(/(?<=^|\n)\n{2,}/gu, '\n');

// output to the files
writeFileSync(readmeFilePath, newReadme, 'utf8');
});