Skip to content

Daily Stats Collector #225

Daily Stats Collector

Daily Stats Collector #225

name: Daily Stats Collector
on:
schedule:
- cron: '1 0 * * *' # Runs at 00:01 UTC every day
workflow_dispatch: # Allows manual triggering
permissions:
contents: write # Needed to commit stats
actions: read # Needed for repository info
pull-requests: read # Needed for some repository data
jobs:
collect-stats:
runs-on: ubuntu-latest
if: github.repository == 'The-AI-Alliance/gofannon'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pandas google-analytics-data PyGithub
- name: Run stats collection script
id: stats
env:
GITHUB_TOKEN: ${{ secrets.STATS_PAT }}
GA_PROPERTY_ID: ${{ secrets.GA_PROPERTY_ID }}
GA_CREDENTIALS: ${{ secrets.GA_CREDENTIALS }}
run: |
python .github/scripts/stats_collector.py
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
git remote set-url origin https://x-access-token:[email protected]/${{ github.repository }}.git
git add website/community/stats.csv
git diff --quiet && git diff --staged --quiet || git commit -m "Update GH and GA Stats"
git push