repo-stats.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. # jgehrcke/github-repo-stats commits to the `github-repo-stats`
  28. # branch by default (NOT gh-pages — Pages is configured to serve
  29. # from that branch). Direct git clone with the PAT surfaces real
  30. # git stderr if anything fails, unlike actions/checkout@v4 which
  31. # swallows errors as opaque "exit code 1".
  32. - name: checkout-data-branch
  33. env:
  34. GH_PAT: ${{ secrets.GHRS_GITHUB_API_TOKEN }}
  35. run: |
  36. git clone --branch github-repo-stats --depth 1 \
  37. "https://x-access-token:${GH_PAT}@github.com/${{ github.repository }}.git" \
  38. data
  39. cd data
  40. git config user.name "github-actions[bot]"
  41. git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
  42. - name: inject-ghcr-pulls
  43. run: |
  44. python3 source/.github/scripts/ghcr_inject.py \
  45. --report data/maziggy/bambuddy/latest-report/report.html \
  46. --csv data/maziggy/bambuddy/ghcr-pulls.csv \
  47. --owner maziggy \
  48. --pkg bambuddy
  49. - name: commit-and-push
  50. working-directory: data
  51. run: |
  52. if [ -z "$(git status --porcelain)" ]; then
  53. echo "no changes — skipping commit"
  54. exit 0
  55. fi
  56. git add maziggy/bambuddy/latest-report/report.html \
  57. maziggy/bambuddy/ghcr-pulls.csv
  58. git commit -m "ghcr-pulls: refresh container downloads chart"
  59. git push