|
1 | | -name: Update Contributors |
| 1 | +name: Update Contributors # Refresh contrib.rocks image cache |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - main |
7 | 4 | workflow_dispatch: |
8 | 5 |
|
| 6 | +permissions: |
| 7 | + contents: write |
| 8 | + pull-requests: write |
| 9 | + |
9 | 10 | jobs: |
10 | | - update-contributors: |
| 11 | + refresh-contrib-cache: |
11 | 12 | runs-on: ubuntu-latest |
12 | | - permissions: |
13 | | - contents: write # Needed for pushing changes. |
14 | | - pull-requests: write # Needed for creating PRs. |
15 | 13 | steps: |
16 | | - - name: Checkout code |
| 14 | + - name: Checkout |
17 | 15 | 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 |
21 | 18 | 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 |
25 | 48 | 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 | +
|
32 | 55 | - name: Create Pull Request |
33 | | - if: steps.check-changes.outputs.changes == 'true' |
| 56 | + if: steps.changes.outputs.changed == 'true' |
34 | 57 | uses: peter-evans/create-pull-request@v7 |
35 | 58 | with: |
36 | 59 | token: ${{ secrets.GITHUB_TOKEN }} |
37 | 60 | commit-message: "docs: update contributors list [skip ci]" |
38 | 61 | committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" |
39 | | - branch: update-contributors |
| 62 | + branch: refresh-contrib-cache |
40 | 63 | delete-branch: true |
41 | | - title: "Update contributors list" |
| 64 | + title: "Refresh contrib.rocks image cache (all READMEs)" |
42 | 65 | 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. |
46 | 67 | base: main |
0 commit comments