Skip to content

Update Download Stats #155

Update Download Stats

Update Download Stats #155

name: Update Download Stats
on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- main
workflow_dispatch:
jobs:
update-downloads:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: pip install requests
- name: Run download script
id: run-script
run: |
python3 scripts/v2/count_downloads.py
echo "total_downloads=$(cat total_downloads.txt)" >> $GITHUB_ENV
- name: Update README
run: |
sed -i "s/Total downloads: [0-9]\+/Total downloads: ${{ env.total_downloads }}/" README.md
- name: Commit changes
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add README.md
git commit -m "chore(workflow): update download stats"
- name: Push changes
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}
git push