-
Notifications
You must be signed in to change notification settings - Fork 16
58 lines (47 loc) · 1.81 KB
/
nightly-snapshot.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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; }