Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/traffic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

# Persists GitHub repository traffic (views and clones) past the default 2-week
# retention period by appending the data to CSV files stored on the `traffic`
# branch. Requires a `TRAFFIC_ACTION_TOKEN` repository secret containing a
# personal access token with `repo` scope so the action can read the traffic API.
name: 'traffic'

permissions: {}

on:
schedule:
# Runs once a week on Sunday.
- cron: '55 23 * * 0'
workflow_dispatch:

jobs:
traffic:
runs-on: ubuntu-latest
permissions:
# Needed to push the CSV files to the `traffic` branch.
contents: write
steps:
- name: 'Checkout traffic branch'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: 'traffic'

- name: 'Collect repository traffic'
uses: sangonzal/repository-traffic-action@404df77a0bfb110f8977fe14ddba62451ec868b7 # v.0.1.6
env:
TRAFFIC_ACTION_TOKEN: ${{ secrets.TRAFFIC_ACTION_TOKEN }}

- name: 'Commit traffic data'
run: |
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add ./traffic/
if git diff --cached --quiet; then
echo 'No traffic changes to commit.'
exit 0
fi
git commit -m 'chore: update repository traffic stats'
git push origin HEAD:traffic
Loading