repo-stats.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. name: GitHub Repo Stats
  2. on:
  3. schedule:
  4. - cron: "0 23 * * *"
  5. workflow_dispatch:
  6. permissions:
  7. contents: write
  8. jobs:
  9. repo-stats:
  10. name: repo-stats
  11. runs-on: ubuntu-latest
  12. steps:
  13. - name: run-ghrs
  14. uses: jgehrcke/github-repo-stats@v1.4.2
  15. with:
  16. repository: maziggy/bambuddy
  17. ghtoken: ${{ secrets.GHRS_GITHUB_API_TOKEN }}
  18. ghpagesprefix: https://maziggy.github.io/bambuddy
  19. # Inject ghcr.io container-download stats (cumulative + 30-day
  20. # sparkline merged into a sidecar CSV so the chart grows beyond
  21. # the 30-day window GHCR exposes). Runs after jgehrcke regenerates
  22. # report.html on gh-pages.
  23. - name: checkout-source
  24. uses: actions/checkout@v4
  25. with:
  26. path: source
  27. - name: checkout-gh-pages
  28. uses: actions/checkout@v4
  29. with:
  30. ref: gh-pages
  31. path: gh-pages
  32. # Same PAT jgehrcke writes gh-pages with — keeps the auth
  33. # chain uniform and avoids the default GITHUB_TOKEN being
  34. # rejected on fetch (root cause of the earlier "exit code 1"
  35. # with no surfaced git stderr).
  36. token: ${{ secrets.GHRS_GITHUB_API_TOKEN }}
  37. fetch-depth: 1
  38. - name: inject-ghcr-pulls
  39. run: |
  40. python3 source/.github/scripts/ghcr_inject.py \
  41. --report gh-pages/maziggy/bambuddy/latest-report/report.html \
  42. --csv gh-pages/maziggy/bambuddy/ghcr-pulls.csv \
  43. --owner maziggy \
  44. --pkg bambuddy
  45. - name: commit-and-push
  46. working-directory: gh-pages
  47. run: |
  48. if [ -z "$(git status --porcelain)" ]; then
  49. echo "no changes — skipping commit"
  50. exit 0
  51. fi
  52. git config user.name "github-actions[bot]"
  53. git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
  54. git add maziggy/bambuddy/latest-report/report.html \
  55. maziggy/bambuddy/ghcr-pulls.csv
  56. git commit -m "ghcr-pulls: refresh container downloads chart"
  57. git push