Skip to content

Commit c943ba7

Browse files
ci: refresh contrib.rocks cache workflow (#8083)
1 parent ded23b7 commit c943ba7

File tree

1 file changed

+48
-27
lines changed

1 file changed

+48
-27
lines changed
Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,67 @@
1-
name: Update Contributors
1+
name: Update Contributors # Refresh contrib.rocks image cache
22

33
on:
4-
push:
5-
branches:
6-
- main
74
workflow_dispatch:
85

6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
910
jobs:
10-
update-contributors:
11+
refresh-contrib-cache:
1112
runs-on: ubuntu-latest
12-
permissions:
13-
contents: write # Needed for pushing changes.
14-
pull-requests: write # Needed for creating PRs.
1513
steps:
16-
- name: Checkout code
14+
- name: Checkout
1715
uses: actions/checkout@v4
18-
- name: Setup Node.js and pnpm
19-
uses: ./.github/actions/setup-node-pnpm
20-
- name: Disable Husky
16+
17+
- name: Bump cacheBust in all README files
2118
run: |
22-
echo "HUSKY=0" >> $GITHUB_ENV
23-
git config --global core.hooksPath /dev/null
24-
- name: Update contributors and format
19+
set -euo pipefail
20+
TS="$(date +%s)"
21+
# Target only the root README.md and localized READMEs under locales/*/README.md
22+
mapfile -t FILES < <(git ls-files README.md 'locales/*/README.md' || true)
23+
24+
if [ "${#FILES[@]}" -eq 0 ]; then
25+
echo "No target README files found." >&2
26+
exit 1
27+
fi
28+
29+
UPDATED=0
30+
for f in "${FILES[@]}"; do
31+
if grep -q 'cacheBust=' "$f"; then
32+
# Use portable sed in GNU environment of ubuntu-latest
33+
sed -i -E "s/cacheBust=[0-9]+/cacheBust=${TS}/g" "$f"
34+
echo "Updated cacheBust in $f"
35+
UPDATED=1
36+
else
37+
echo "Warning: cacheBust parameter not found in $f" >&2
38+
fi
39+
done
40+
41+
if [ "$UPDATED" -eq 0 ]; then
42+
echo "No files were updated. Ensure READMEs embed contrib.rocks with cacheBust param." >&2
43+
exit 1
44+
fi
45+
46+
- name: Detect changes
47+
id: changes
2548
run: |
26-
pnpm update-contributors
27-
npx prettier --write README.md locales/*/README.md
28-
if git diff --quiet; then echo "changes=false" >> $GITHUB_OUTPUT; else echo "changes=true" >> $GITHUB_OUTPUT; fi
29-
id: check-changes
30-
env:
31-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
if git diff --quiet; then
50+
echo "changed=false" >> $GITHUB_OUTPUT
51+
else
52+
echo "changed=true" >> $GITHUB_OUTPUT
53+
fi
54+
3255
- name: Create Pull Request
33-
if: steps.check-changes.outputs.changes == 'true'
56+
if: steps.changes.outputs.changed == 'true'
3457
uses: peter-evans/create-pull-request@v7
3558
with:
3659
token: ${{ secrets.GITHUB_TOKEN }}
3760
commit-message: "docs: update contributors list [skip ci]"
3861
committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
39-
branch: update-contributors
62+
branch: refresh-contrib-cache
4063
delete-branch: true
41-
title: "Update contributors list"
64+
title: "Refresh contrib.rocks image cache (all READMEs)"
4265
body: |
43-
Automated update of contributors list and related files
44-
45-
This PR was created automatically by a GitHub Action workflow and includes all changed files.
66+
Automated refresh of the contrib.rocks image cache by bumping the cacheBust parameter in README.md and locales/*/README.md.
4667
base: main

0 commit comments

Comments
 (0)