Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 49 additions & 28 deletions .github/workflows/update-contributors.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,67 @@
name: Update Contributors
name: Update Contributors # Refresh contrib.rocks image cache
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? The workflow filename is still update-contributors.yml but its purpose has completely changed to refreshing contrib.rocks cache. Should we rename this file to something like refresh-contrib-cache.yml to better reflect its new purpose?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style suggestion: The inline comment after the workflow name is unconventional. Consider either removing it or moving it to a separate comment line:

Suggested change
name: Update Contributors # Refresh contrib.rocks image cache
name: Refresh Contrib.rocks Cache
# Refreshes the contrib.rocks image cache by updating cacheBust parameter


on:
push:
branches:
- main
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
update-contributors:
refresh-contrib-cache:
runs-on: ubuntu-latest
permissions:
contents: write # Needed for pushing changes.
pull-requests: write # Needed for creating PRs.
steps:
- name: Checkout code
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
- name: Disable Husky

- name: Bump cacheBust in all README files
run: |
echo "HUSKY=0" >> $GITHUB_ENV
git config --global core.hooksPath /dev/null
- name: Update contributors and format
set -euo pipefail
TS="$(date +%s)"
# Target only the root README.md and localized READMEs under locales/*/README.md
mapfile -t FILES < <(git ls-files README.md 'locales/*/README.md' || true)

if [ "${#FILES[@]}" -eq 0 ]; then
echo "No target README files found." >&2
exit 1
fi

UPDATED=0
for f in "${FILES[@]}"; do
if grep -q 'cacheBust=' "$f"; then
# Use portable sed in GNU environment of ubuntu-latest
sed -i -E "s/cacheBust=[0-9]+/cacheBust=${TS}/g" "$f"
echo "Updated cacheBust in $f"
UPDATED=1
else
echo "Warning: cacheBust parameter not found in $f" >&2
fi
done

if [ "$UPDATED" -eq 0 ]; then
echo "No files were updated. Ensure READMEs embed contrib.rocks with cacheBust param." >&2
exit 1
fi

- name: Detect changes
id: changes
run: |
pnpm update-contributors
npx prettier --write README.md locales/*/README.md
if git diff --quiet; then echo "changes=false" >> $GITHUB_OUTPUT; else echo "changes=true" >> $GITHUB_OUTPUT; fi
id: check-changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if git diff --quiet; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Create Pull Request
if: steps.check-changes.outputs.changes == 'true'
if: steps.changes.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "docs: update contributors list [skip ci]"
commit-message: "chore: refresh contrib.rocks image cache across all READMEs [skip ci]"
committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
branch: update-contributors
branch: refresh-contrib-cache
delete-branch: true
title: "Update contributors list"
title: "Refresh contrib.rocks image cache (all READMEs)"
body: |
Automated update of contributors list and related files

This PR was created automatically by a GitHub Action workflow and includes all changed files.
Automated refresh of the contrib.rocks image cache by bumping the cacheBust parameter in README.md and locales/*/README.md.
base: main
Loading