mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 15:33:56 +08:00
ci(website): refresh the contributor list weekly (#17116)
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
name: Refresh website contributors
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "17 6 * * 1"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: website-contributors
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
refresh:
|
||||
if: github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
env:
|
||||
BRANCH: chore/refresh-website-contributors
|
||||
steps:
|
||||
# Pull requests pushed with GITHUB_TOKEN do not start CI, so prefer a
|
||||
# token that can. Without it, close and reopen the pull request.
|
||||
- name: Check out the repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
token: ${{ secrets.WEBSITE_CONTRIBUTORS_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
- name: Set up Python for website assets
|
||||
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
||||
with:
|
||||
python-version: "3.12"
|
||||
cache: pip
|
||||
cache-dependency-path: website/requirements.txt
|
||||
- name: Set up Node.js for skill discovery and Worker checks
|
||||
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||
with:
|
||||
package-manager-cache: false
|
||||
node-version-file: .nvmrc
|
||||
- name: Install website build dependencies
|
||||
run: |
|
||||
npm ci --omit=dev --ignore-scripts
|
||||
sudo apt-get update
|
||||
sudo apt-get install --no-install-recommends -y libcairo2 fonts-dejavu-core
|
||||
python3 -m pip install -r website/requirements.txt
|
||||
- name: Refresh the contributor list
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
python3 scripts/website.py contributors
|
||||
python3 scripts/website.py sync
|
||||
python3 scripts/website.py translations extract
|
||||
# The snapshot date and revision change on every run; only people and
|
||||
# commit counts justify a pull request.
|
||||
- name: Compare with the published list
|
||||
id: changes
|
||||
run: |
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
path = "website/public/contributors/people.json"
|
||||
before = json.loads(subprocess.run(["git", "show", f"HEAD:{path}"], capture_output=True, text=True, check=True).stdout)
|
||||
with open(path, encoding="utf-8") as file:
|
||||
after = json.load(file)
|
||||
changed = before["contributors"] != after["contributors"]
|
||||
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as output:
|
||||
output.write(f"changed={str(changed).lower()}\n")
|
||||
output.write(f"before={len(before['contributors'])}\nafter={len(after['contributors'])}\n")
|
||||
print("Contributor list changed." if changed else "Contributor list is current.")
|
||||
PY
|
||||
- name: Check the refreshed website
|
||||
if: steps.changes.outputs.changed == 'true'
|
||||
run: python3 scripts/website.py check
|
||||
- name: Open or update the pull request
|
||||
if: steps.changes.outputs.changed == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.WEBSITE_CONTRIBUTORS_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
BEFORE: ${{ steps.changes.outputs.before }}
|
||||
AFTER: ${{ steps.changes.outputs.after }}
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git switch -c "$BRANCH"
|
||||
git add website/public/contributors website/locales
|
||||
git commit -m "chore(website): refresh contributor list"
|
||||
git push --force origin "$BRANCH"
|
||||
body="Weekly refresh of the contributor list from \`main\` at ${GITHUB_SHA::10}: $BEFORE → $AFTER contributors.
|
||||
|
||||
Generated by the Refresh website contributors workflow, which ran \`python3 scripts/website.py check\` before opening this pull request. If checks did not start, close and reopen this pull request."
|
||||
if [[ -z "$(gh pr list --head "$BRANCH" --state open --json number --jq '.[].number')" ]]; then
|
||||
gh pr create --base main --head "$BRANCH" \
|
||||
--title "chore(website): refresh contributor list" --body "$body"
|
||||
else
|
||||
gh pr edit "$BRANCH" --body "$body"
|
||||
fi
|
||||
@@ -776,6 +776,7 @@ const PATH_SCOPES = {
|
||||
"README*.md",
|
||||
"docs/readme/README*.md",
|
||||
".github/workflows/website-check.yml",
|
||||
".github/workflows/website-contributors.yml",
|
||||
".github/workflows/website-pages.yml",
|
||||
],
|
||||
};
|
||||
|
||||
@@ -224,6 +224,13 @@ commit and fetches its public avatar for `public/contributors/avatars.png`.
|
||||
Review and commit the JSON, PNG, rendered page, and catalog updates together.
|
||||
Builds and offline checks use the saved snapshot.
|
||||
|
||||
The `Refresh website contributors` workflow runs these commands every Monday
|
||||
and on demand. When people or commit counts change, it opens or updates a pull
|
||||
request from `chore/refresh-website-contributors`. Set the
|
||||
`WEBSITE_CONTRIBUTORS_TOKEN` Actions secret to a token that can push branches
|
||||
and open pull requests so CI starts on them. Without it, the workflow uses
|
||||
`GITHUB_TOKEN`, and CI starts only after you close and reopen the pull request.
|
||||
|
||||
## Search and sharing metadata
|
||||
|
||||
`https://rea.tools/` is the preferred public origin. Each content page has one
|
||||
|
||||
Reference in New Issue
Block a user