-
Notifications
You must be signed in to change notification settings - Fork 63
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
docs: Add sponsors to README #287
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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,34 @@ | ||
name: Data Fetch | ||
|
||
on: | ||
schedule: | ||
- cron: "0 8 * * *" # Every day at 1am PDT | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.WORKFLOW_PUSH_BOT_TOKEN }} | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
|
||
- name: Install npm packages | ||
run: npm install | ||
|
||
- name: Update README with latest sponsor data | ||
run: npm run build:readme | ||
|
||
- name: Setup Git | ||
run: | | ||
git config user.name "GitHub Actions Bot" | ||
git config user.email "<[email protected]>" | ||
|
||
- name: Save updated files | ||
run: | | ||
chmod +x ./tools/commit-readme.sh | ||
./tools/commit-readme.sh |
This file contains 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
This file contains 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
This file contains 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,18 @@ | ||
#!/bin/bash | ||
|
||
#------------------------------------------------------------------------------ | ||
# Commits the data files if any have changed | ||
#------------------------------------------------------------------------------ | ||
|
||
if [ -z "$(git status --porcelain)" ]; then | ||
echo "Data did not change." | ||
else | ||
echo "Data changed!" | ||
|
||
# commit the result | ||
git add README.md | ||
git commit -m "docs: Update README sponsors" | ||
|
||
# push back to source control | ||
git push origin HEAD | ||
fi |
This file contains 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,57 @@ | ||
/** | ||
* @fileoverview Script to update the README with sponsors details in all packages. | ||
* | ||
* node tools/update-readme.js | ||
* | ||
* @author Milos Djermanovic | ||
*/ | ||
|
||
//----------------------------------------------------------------------------- | ||
// Requirements | ||
//----------------------------------------------------------------------------- | ||
|
||
import { readFileSync, writeFileSync } from "node:fs"; | ||
import got from "got"; | ||
|
||
//----------------------------------------------------------------------------- | ||
// Data | ||
//----------------------------------------------------------------------------- | ||
|
||
const SPONSORS_URL = | ||
"https://raw.githubusercontent.com/eslint/eslint.org/main/includes/sponsors.md"; | ||
|
||
const README_FILE_PATH = "./README.md"; | ||
|
||
//----------------------------------------------------------------------------- | ||
// Helpers | ||
//----------------------------------------------------------------------------- | ||
|
||
/** | ||
* Fetches the latest sponsors from the website. | ||
* @returns {Promise<string>}} Prerendered sponsors markdown. | ||
*/ | ||
async function fetchSponsorsMarkdown() { | ||
return got(SPONSORS_URL).text(); | ||
} | ||
|
||
//----------------------------------------------------------------------------- | ||
// Main | ||
//----------------------------------------------------------------------------- | ||
|
||
(async () => { | ||
const allSponsors = await fetchSponsorsMarkdown(); | ||
|
||
// read readme file | ||
const readme = readFileSync(README_FILE_PATH, "utf8"); | ||
|
||
let newReadme = readme.replace( | ||
/<!--sponsorsstart-->[\w\W]*?<!--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(README_FILE_PATH, newReadme, "utf8"); | ||
})(); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this IIFE actually needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed it now.