-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (73 loc) · 2.75 KB
/
update-stats.yml
File metadata and controls
85 lines (73 loc) · 2.75 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Update Statistics
on:
# Run on push to main branch
push:
branches:
- main
# Run daily at midnight UTC
schedule:
- cron: '0 0 * * *'
# Allow manual trigger
workflow_dispatch:
permissions:
contents: write
pull-requests: read
jobs:
update-stats:
name: Generate and Update Statistics
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for git log analysis
- name: Enable cache file tracking for CI
run: |
# In CI, we need to track the cache file changes
git update-index --no-skip-worktree scripts/pr_reviews_cache.json 2>/dev/null || true
- name: Clone Templates repository
run: |
git clone https://github.com/Domain-Connect/Templates.git Templates
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r scripts/requirements.txt
- name: Generate statistics
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python scripts/update_stats.py --folder Templates --repo-owner Domain-Connect --repo-name Templates
- name: Check for changes
id: check_changes
run: |
if git diff --quiet docs/stats.json scripts/pr_reviews_cache.json; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add docs/stats.json scripts/pr_reviews_cache.json
git commit -m "Update statistics - $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
git push
- name: Summary
run: |
echo "### Statistics Update Complete 📊" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Statistics have been generated and updated." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.check_changes.outputs.changed }}" == "true" ]; then
echo "✅ Changes detected and committed" >> $GITHUB_STEP_SUMMARY
else
echo "ℹ️ No changes detected" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "View dashboard: [Statistics Dashboard](https://raw.githack.com/${{ github.repository }}/master/docs/index.html)" >> $GITHUB_STEP_SUMMARY