Nightly Snapshot of Release Download Statistics #12
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 1 * * *' # Runs every day at 1:00 AM (UTC) | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
collect-stats: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Checkout the specific "release_stats" branch | |
- name: Checkout "release_stats" branch | |
uses: actions/checkout@v3 | |
with: | |
ref: release_stats # Always operate on the release_stats branch | |
# 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. 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 | |
# 6. Configure Git for committing | |
- name: Configure Git | |
run: | | |
git config --local user.email "sapmachine@sap.com" | |
git config --local user.name "SapMachine Github Actions Bot" | |
# 7. Commit and push the 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; } |