From 007c7d0ebd1dfdeb5606349aa245667af60c3453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=A3=A8=EB=B0=80LuMir?= Date: Mon, 22 Sep 2025 17:11:30 +0900 Subject: [PATCH] ci: centralize `update-readme` workflow --- .github/workflows/update-readme.yml | 35 ++++-------------- .gitignore | 3 ++ package.json | 3 +- tools/commit-readme.sh | 18 ---------- tools/update-readme.js | 55 ----------------------------- 5 files changed, 11 insertions(+), 103 deletions(-) delete mode 100644 tools/commit-readme.sh delete mode 100644 tools/update-readme.js diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml index ee984ede..96d09866 100644 --- a/.github/workflows/update-readme.yml +++ b/.github/workflows/update-readme.yml @@ -1,34 +1,13 @@ -name: Data Fetch +name: update-readme on: schedule: - - cron: "0 8 * * *" # Every day at 1am PDT + - cron: "0 8 * * *" # Runs every day at 08:00 AM UTC + workflow_dispatch: jobs: - build: - 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 - - - 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 "" - - - name: Save updated files - run: | - chmod +x ./tools/commit-readme.sh - ./tools/commit-readme.sh + update-readme: + uses: eslint/workflows/.github/workflows/update-readme.yml@main + secrets: + workflow_push_bot_token: ${{ secrets.WORKFLOW_PUSH_BOT_TOKEN }} diff --git a/.gitignore b/.gitignore index 76b12079..6589ac38 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ dist/ src/build test.css + +# Automatically generated files by GitHub Actions workflow +tools/update-readme.js diff --git a/package.json b/package.json index b86123a1..0e49029f 100644 --- a/package.json +++ b/package.json @@ -62,12 +62,12 @@ "build:cts": "node -e \"fs.copyFileSync('dist/esm/index.d.ts', 'dist/cjs/index.d.cts')\" && node tools/update-cts.js dist/cjs/types.cts dist/cjs/index.d.cts", "build:rules": "node tools/build-rules.js", "build": "npm run build:rules && rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts", - "build:readme": "node tools/update-readme.js", "build:update-rules-docs": "node tools/update-rules-docs.js", "build:baseline": "node tools/generate-baseline.js", "prepare": "npm run build", "pretest": "npm run build", "lint": "eslint", + "lint:fix": "eslint --fix", "fmt": "prettier --write .", "fmt:check": "prettier --check .", "test": "mocha \"tests/**/*.test.js\"", @@ -96,7 +96,6 @@ "eslint": "^9.35.0", "eslint-config-eslint": "^13.0.0", "eslint-plugin-eslint-plugin": "^6.3.2", - "got": "^14.4.2", "lint-staged": "^15.2.7", "mdast-util-from-markdown": "^2.0.2", "mdn-data": "^2.24.0", diff --git a/tools/commit-readme.sh b/tools/commit-readme.sh deleted file mode 100644 index dcbc986b..00000000 --- a/tools/commit-readme.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/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 diff --git a/tools/update-readme.js b/tools/update-readme.js deleted file mode 100644 index 1c9aa22c..00000000 --- a/tools/update-readme.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @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} Prerendered sponsors markdown. - */ -async function fetchSponsorsMarkdown() { - return got(SPONSORS_URL).text(); -} - -//----------------------------------------------------------------------------- -// Main -//----------------------------------------------------------------------------- - -const allSponsors = await fetchSponsorsMarkdown(); - -// read readme file -const readme = readFileSync(README_FILE_PATH, "utf8"); - -let newReadme = readme.replace( - /[\s\S]*?/u, - `\n\n${allSponsors}\n`, -); - -// 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");