-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (103 loc) · 3.6 KB
/
generate_report.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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Generate Starred Repos Report
on:
schedule:
- cron: '30 22 * * *' # Run daily at 6:30am UTC+8
workflow_dispatch: # Allow manual trigger
# push:
# branches:
# - master
jobs:
generate-report:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install dependencies
run: |
uv sync --all-extras --dev
- name: Restore commit timestamps cache
uses: actions/cache/restore@v4
with:
path: commit_timestamps.json
key: commit-timestamps-${{ github.run_id }}
restore-keys: |
commit-timestamps-
- name: Restore report cache
uses: actions/cache/restore@v4
with:
path: reports/
key: report-cache-${{ github.run_id }}
restore-keys: |
report-cache-
- name: Set TODAY variable
id: set_date
run: |
echo "TODAY=$(TZ=Asia/Shanghai date +'%Y-%m-%d')" >> $GITHUB_ENV
echo "TODAY=$(TZ=Asia/Shanghai date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Generate report
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
REPO_LIMIT: ${{ vars.REPO_LIMIT }}
EMPTY_REPO_CONSECUTIVE_LIMIT: ${{ vars.EMPTY_REPO_CONSECUTIVE_LIMIT }}
run: uv run src/main.py
id: generate_report
- name: Save commit timestamps cache
uses: actions/cache/save@v4
with:
path: commit_timestamps.json
key: commit-timestamps-${{ github.run_id }}
- name: Save report cache
uses: actions/cache/save@v4
with:
path: reports/
key: report-cache-${{ github.run_id }}
- name: Create Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
name: "Activity Report ${{ env.TODAY }}"
tag_name: ${{ env.TODAY }}
body_path: ${{ steps.generate_report.outputs.report_file }}
files: |
${{ steps.generate_report.outputs.report_file }}
${{ steps.generate_report.outputs.report_json_file }}
reports/feed.json
- name: Create latest symbolic links
run: |
cp ${{ steps.generate_report.outputs.report_json_file }} reports/recent_commits_latest.json
cp ${{ steps.generate_report.outputs.report_file }} reports/recent_commits_latest.md
- name: Copy latest reports to docs
run: |
cp reports/recent_commits_latest.json docs/recent_commits_latest.json
cp reports/recent_commits_latest.md docs/recent_commits_latest.md
- name: Upload latest reports
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
tag_name: latest
files: |
reports/recent_commits_latest.json
reports/recent_commits_latest.md
reports/feed.json
prerelease: true
- name: Force update pages branch
run: |
git branch -D pages || true
git checkout -b pages
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add docs/recent_commits_latest.json docs/recent_commits_latest.md
git commit -m "Update reports for ${{ env.TODAY }}" || exit 0
git push origin pages --force