update-contributors.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. name: Update Contributors # Refresh contrib.rocks image cache
  2. on:
  3. workflow_dispatch:
  4. permissions:
  5. contents: write
  6. pull-requests: write
  7. jobs:
  8. refresh-contrib-cache:
  9. runs-on: ubuntu-latest
  10. steps:
  11. - name: Checkout
  12. uses: actions/checkout@v4
  13. - name: Bump cacheBust in all README files
  14. run: |
  15. set -euo pipefail
  16. TS="$(date +%s)"
  17. # Target only the root README.md and localized READMEs under locales/*/README.md
  18. mapfile -t FILES < <(git ls-files README.md 'locales/*/README.md' || true)
  19. if [ "${#FILES[@]}" -eq 0 ]; then
  20. echo "No target README files found." >&2
  21. exit 1
  22. fi
  23. UPDATED=0
  24. for f in "${FILES[@]}"; do
  25. if grep -q 'cacheBust=' "$f"; then
  26. # Use portable sed in GNU environment of ubuntu-latest
  27. sed -i -E "s/cacheBust=[0-9]+/cacheBust=${TS}/g" "$f"
  28. echo "Updated cacheBust in $f"
  29. UPDATED=1
  30. else
  31. echo "Warning: cacheBust parameter not found in $f" >&2
  32. fi
  33. done
  34. if [ "$UPDATED" -eq 0 ]; then
  35. echo "No files were updated. Ensure READMEs embed contrib.rocks with cacheBust param." >&2
  36. exit 1
  37. fi
  38. - name: Detect changes
  39. id: changes
  40. run: |
  41. if git diff --quiet; then
  42. echo "changed=false" >> $GITHUB_OUTPUT
  43. else
  44. echo "changed=true" >> $GITHUB_OUTPUT
  45. fi
  46. - name: Create Pull Request
  47. if: steps.changes.outputs.changed == 'true'
  48. uses: peter-evans/create-pull-request@v7
  49. with:
  50. token: ${{ secrets.GITHUB_TOKEN }}
  51. commit-message: "docs: update contributors list [skip ci]"
  52. committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
  53. branch: refresh-contrib-cache
  54. delete-branch: true
  55. title: "Refresh contrib.rocks image cache (all READMEs)"
  56. body: |
  57. Automated refresh of the contrib.rocks image cache by bumping the cacheBust parameter in README.md and locales/*/README.md.
  58. base: main