Nightly Snapshot of Release Download Statistics #126
This file contains 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: Nightly Snapshot of Release Download Statistics | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs every day at 12:00 AM (UTC) | |
workflow_dispatch: # Allows manual triggering | |
permissions: | |
contents: write # Ensure write permissions | |
jobs: | |
collect-stats: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 # Fetch full history to ensure the branch is fully available | |
# 2. Set up Python environment | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
# 3. Install required Python dependencies | |
- name: Install dependencies | |
run: | | |
pip install requests pandas | |
# 4. Create stats directory (if it doesn't exist) | |
- name: Create stats directory | |
run: mkdir -p stats | |
# 5. Checkout the release_stats branch | |
- name: Checkout release_stats branch | |
run: | | |
git checkout release_stats || git checkout -b release_stats | |
# 6. Run the Python script to fetch and append download stats | |
- name: Run Python script to fetch and append download stats | |
run: python .github/scripts/fetch_and_append_stats.py | |
# 7. Configure Git for committing | |
- name: Configure Git | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "SapMachine Github Actions Bot" | |
# 8. Commit and push changes to the "release_stats" branch | |
- name: Commit and push changes | |
run: | | |
git add stats/release_stats*.csv | |
git commit -m "Add nightly snapshot for $(date +'%Y-%m-%d %H:%M:%S')" || echo "No changes to commit" | |
git push origin release_stats || { echo "Push failed, please check the logs"; exit 1; } |