Collect GitHub campaign metrics #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Collect GitHub campaign metrics | |
| on: | |
| schedule: | |
| # Once per day is sufficient for GitHub's rolling 14-day traffic window. | |
| - cron: "17 06 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| # GitHub traffic endpoints are restricted to repository write access. | |
| # The collector itself performs GET requests only and never mutates the repository. | |
| contents: write | |
| jobs: | |
| collect: | |
| name: Collect aggregate repository and release metrics | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Check out metric collector | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Collect GitHub traffic and release downloads | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.METRICS_GITHUB_TOKEN || github.token }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| METRICS_OUTPUT: tracking/reports/github_release_metrics.json | |
| run: python3 scripts/collect_github_release_metrics.py | |
| - name: Upload campaign metrics report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: github-campaign-metrics-${{ github.run_id }} | |
| path: tracking/reports/github_release_metrics.json | |
| if-no-files-found: error | |
| retention-days: 45 |