Archive Clone Stats #103
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: Archive Clone Stats | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # runs daily at midnight UTC | |
| workflow_dispatch: # lets you trigger it manually too | |
| permissions: | |
| contents: write # allows GITHUB_TOKEN to push commits back to repo | |
| jobs: | |
| archive: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Fetch traffic data | |
| run: | | |
| mkdir -p data | |
| curl -s \ | |
| -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "https://api.github.com/repos/fosres/SecEng-Exercises/traffic/clones?per=day" \ | |
| >> data/clones_raw.json | |
| curl -s \ | |
| -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "https://api.github.com/repos/fosres/SecEng-Exercises/traffic/views?per=day" \ | |
| >> data/views_raw.json | |
| - name: Commit data | |
| run: | | |
| git config user.email "action@github.com" | |
| git config user.name "GitHub Action" | |
| git add data/clones_raw.json data/views_raw.json | |
| git diff --staged --quiet || git commit -m "chore: daily traffic snapshot" | |
| git pull --rebase origin main | |
| git push | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |