Skip to content

Update sponsors

Update sponsors #18

name: Update sponsors
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch: {}
permissions:
contents: write
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up pnpm
uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v6
with:
node-version: lts/*
cache: pnpm
- name: Fetch sponsor data
run: |
set -euo pipefail
curl -fsSL https://sponsors.esm.is/sponsors-docs.json \
-o packages/docs/.vitepress/theme/components/sponsors.json
curl -fsSL https://sponsors.esm.is/sponsors-docs-html \
-o /tmp/sponsors-docs.html
python - <<'PY'
from pathlib import Path
readme_path = Path("README.md")
html_path = Path("/tmp/sponsors-docs.html")
start_marker = "<!--sponsors start-->"
end_marker = "<!--sponsors end-->"
content = readme_path.read_text()
start_index = content.find(start_marker)
end_index = content.find(end_marker)
if start_index == -1 or end_index == -1 or end_index < start_index:
raise SystemExit("Could not find sponsors markers in README.md")
before = content[:start_index]
after = content[end_index + len(end_marker):]
html = html_path.read_text().strip()
new_content = f"{before}{html}{after}"
if new_content != content:
readme_path.write_text(new_content)
PY
# allows oxfmt to run on commit
- name: Install deps
run: |
pnpm install --frozen-lockfile
- name: Format sponsor files
run: |
pnpm exec oxfmt packages/docs/.vitepress/theme/components/sponsors.json README.md
- name: Check for changes
id: sponsors-after
run: |
if git diff --quiet -- packages/docs/.vitepress/theme/components/sponsors.json README.md; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit
if: steps.sponsors-after.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add packages/docs/.vitepress/theme/components/sponsors.json README.md
git commit -m "chore: update sponsors" --no-verify
git push