From 5c789dd2ed413371299b763580cd3f906458b2f2 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 19 Jul 2024 11:37:43 +0530 Subject: [PATCH] ci: auto update sponsors in README --- .github/workflows/update-readme.yml | 35 +++++++++++++++++++++++++++++ tools/commit-readme.sh | 18 +++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/update-readme.yml create mode 100644 tools/commit-readme.sh diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml new file mode 100644 index 00000000..deb41800 --- /dev/null +++ b/.github/workflows/update-readme.yml @@ -0,0 +1,35 @@ +name: Data Fetch + +on: + schedule: + - cron: "0 8 * * *" # Every day at 1am PDT + workflow_dispatch: + pull_request: + +jobs: + update-readme: + 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 --force + + - name: Update README with latest team and 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 diff --git a/tools/commit-readme.sh b/tools/commit-readme.sh new file mode 100644 index 00000000..baa69a50 --- /dev/null +++ b/tools/commit-readme.sh @@ -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 packages/**/README.md + git commit -m "docs: Update README sponsors" + + # push back to source control + git push origin HEAD +fi