Nightly Snapshot of Release Download Statistics #1
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 | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
collect-stats: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Checkout the current branch | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref_name }} # Dynamically use the current 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. 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 | |
# 5. Configure Git for committing | |
- name: Configure Git | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "SapMachine Github Actions Bot" | |
# 6. Stash any changes before rebase | |
- name: Stash changes | |
run: | | |
git add . | |
git stash | |
# 7. Fetch the latest changes and rebase | |
- name: Fetch and rebase | |
run: | | |
git fetch origin ${{ github.ref_name }} | |
git rebase origin/${{ github.ref_name }} || { echo "Rebase failed, resolving conflicts"; exit 1; } | |
# 8. Apply stashed changes after rebase | |
- name: Apply stashed changes | |
run: | | |
git stash pop || { echo "No stashed changes to apply"; } | |
# 9. Commit and push the changes back to the current branch | |
- name: Commit and push changes | |
run: | | |
git add 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 ${{ github.ref_name }} || { echo "Push failed, please check the logs"; exit 1; } |