Skip to content

Commit dabcaa3

Browse files
committed
🎉 Merge: single repo with Docusaurus frontend
1 parent 3833200 commit dabcaa3

15 files changed

Lines changed: 623 additions & 286 deletions

File tree

.github/workflows/daily_report.yml

Lines changed: 73 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,110 @@
1-
name: Daily GitHub Trending Report
1+
name: Daily Report & Deploy
22

33
on:
4-
# Run daily at 00:00 UTC (08:00 Beijing Time)
54
schedule:
6-
- cron: '0 0 * * *'
7-
8-
# Allow manual trigger
5+
- cron: '0 0 * * *' # 每天 UTC 00:00
96
workflow_dispatch:
10-
inputs:
11-
language:
12-
description: 'Programming language filter (leave empty for all)'
13-
required: false
14-
default: ''
15-
since:
16-
description: 'Time range (daily, weekly, monthly)'
17-
required: false
18-
default: 'daily'
19-
analysis_type:
20-
description: 'Analysis type (comprehensive, brief, technical)'
21-
required: false
22-
default: 'comprehensive'
7+
push:
8+
branches: [main]
9+
10+
permissions:
11+
contents: write
12+
pages: write
13+
id-token: write
14+
15+
concurrency:
16+
group: pages
17+
cancel-in-progress: false
2318

2419
env:
2520
PYTHON_VERSION: '3.11'
21+
NODE_VERSION: '20'
2622

2723
jobs:
24+
# Job 1: 生成报告(仅定时或手动触发)
2825
generate-report:
26+
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
2927
runs-on: ubuntu-latest
30-
3128
steps:
32-
- name: 📥 Checkout repository
33-
uses: actions/checkout@v4
29+
- uses: actions/checkout@v4
3430

35-
- name: 🐍 Set up Python
31+
- name: 🐍 Setup Python
3632
uses: actions/setup-python@v5
3733
with:
3834
python-version: ${{ env.PYTHON_VERSION }}
39-
cache: 'pip'
4035

41-
- name: 📦 Install dependencies
42-
run: |
43-
python -m pip install --upgrade pip
44-
pip install -r requirements.txt
36+
- name: 📦 Install Python dependencies
37+
run: pip install -r requirements.txt
4538

46-
- name: 🚀 Generate trending report
39+
- name: 🚀 Generate report
4740
env:
4841
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
4942
LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }}
5043
LLM_MODEL: ${{ secrets.LLM_MODEL }}
5144
GITHUB_API_TOKEN: ${{ secrets.GITHUB_API_TOKEN }}
52-
GITHUB_TOKEN: ${{ secrets.DATA_REPO_TOKEN }}
53-
DATA_REPO_OWNER: ${{ github.repository_owner }}
54-
DATA_REPO_NAME: github-trending-reporter-data
45+
run: python main.py --local --no-push
46+
47+
- name: 📁 Move output to reports
5548
run: |
56-
# Set language filter if provided
57-
LANGUAGE_ARG=""
58-
if [ -n "${{ github.event.inputs.language }}" ]; then
59-
LANGUAGE_ARG="-l ${{ github.event.inputs.language }}"
49+
DATE=$(date +%Y-%m-%d)
50+
YEAR=$(date +%Y)
51+
MONTH=$(date +%m)
52+
mkdir -p reports/$YEAR/$MONTH data/$YEAR/$MONTH
53+
if [ -f output/$DATE.md ]; then
54+
cp output/$DATE.md reports/$YEAR/$MONTH/
55+
fi
56+
if [ -f output/$DATE.json ]; then
57+
cp output/$DATE.json data/$YEAR/$MONTH/
6058
fi
61-
62-
# Set since filter (use input or default)
63-
SINCE_ARG="-s ${{ github.event.inputs.since || 'daily' }}"
64-
65-
# Set analysis type (use input or default)
66-
ANALYSIS_ARG="-a ${{ github.event.inputs.analysis_type || 'comprehensive' }}"
67-
68-
# Run the report generator
69-
python main.py $LANGUAGE_ARG $SINCE_ARG $ANALYSIS_ARG --local
70-
71-
- name: 📤 Upload artifacts
72-
uses: actions/upload-artifact@v4
73-
with:
74-
name: trending-report-${{ github.run_id }}
75-
path: output/
76-
retention-days: 30
7759
78-
- name: 📊 Report summary
60+
- name: 📤 Commit and push
7961
run: |
80-
echo "## 📈 GitHub Trending Report" >> $GITHUB_STEP_SUMMARY
81-
echo "" >> $GITHUB_STEP_SUMMARY
82-
echo "Report generated successfully!" >> $GITHUB_STEP_SUMMARY
83-
echo "" >> $GITHUB_STEP_SUMMARY
84-
if [ -f "output/*.md" ]; then
85-
echo "### Report Preview" >> $GITHUB_STEP_SUMMARY
86-
head -50 output/*.md >> $GITHUB_STEP_SUMMARY
87-
fi
62+
git config user.name "github-actions[bot]"
63+
git config user.email "github-actions[bot]@users.noreply.github.com"
64+
git add reports/ data/
65+
git diff --staged --quiet || git commit -m "📈 Add report for $(date +%Y-%m-%d)"
66+
git push
8867
89-
# Optional: Generate reports for specific languages
90-
generate-language-reports:
68+
# Job 2: 构建部署网站
69+
build-deploy:
9170
runs-on: ubuntu-latest
92-
if: github.event_name == 'schedule'
93-
needs: generate-report
94-
95-
strategy:
96-
matrix:
97-
language: [python, javascript, typescript, go, rust]
98-
fail-fast: false
99-
71+
needs: [generate-report]
72+
if: always() && (needs.generate-report.result == 'success' || needs.generate-report.result == 'skipped')
10073
steps:
101-
- name: 📥 Checkout repository
102-
uses: actions/checkout@v4
74+
- uses: actions/checkout@v4
75+
with:
76+
ref: main
77+
fetch-depth: 0
10378

104-
- name: 🐍 Set up Python
105-
uses: actions/setup-python@v5
79+
- name: 🔄 Pull latest changes
80+
run: git pull origin main
81+
82+
- name: 🟢 Setup Node.js
83+
uses: actions/setup-node@v4
10684
with:
107-
python-version: ${{ env.PYTHON_VERSION }}
108-
cache: 'pip'
85+
node-version: ${{ env.NODE_VERSION }}
10986

11087
- name: 📦 Install dependencies
111-
run: |
112-
python -m pip install --upgrade pip
113-
pip install -r requirements.txt
88+
run: npm install
11489

115-
- name: 🚀 Generate ${{ matrix.language }} trending report
116-
env:
117-
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
118-
LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }}
119-
LLM_MODEL: ${{ secrets.LLM_MODEL }}
120-
GITHUB_API_TOKEN: ${{ secrets.GITHUB_API_TOKEN }}
121-
GITHUB_TOKEN: ${{ secrets.DATA_REPO_TOKEN }}
122-
DATA_REPO_OWNER: ${{ github.repository_owner }}
123-
DATA_REPO_NAME: github-trending-reporter-data
124-
run: |
125-
python main.py -l ${{ matrix.language }} -a brief --local
126-
continue-on-error: true
90+
- name: 🔧 Generate sidebar
91+
run: npm run generate-sidebar
92+
93+
- name: 🏗️ Build
94+
run: npm run build
12795

128-
- name: 📤 Upload artifacts
129-
uses: actions/upload-artifact@v4
96+
- name: 📤 Upload artifact
97+
uses: actions/upload-pages-artifact@v3
13098
with:
131-
name: trending-report-${{ matrix.language }}-${{ github.run_id }}
132-
path: output/
133-
retention-days: 30
99+
path: build
100+
101+
deploy:
102+
environment:
103+
name: github-pages
104+
url: ${{ steps.deployment.outputs.page_url }}
105+
runs-on: ubuntu-latest
106+
needs: build-deploy
107+
steps:
108+
- name: 🚀 Deploy to GitHub Pages
109+
id: deployment
110+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,32 @@ __pycache__/
33
*.py[cod]
44
*$py.class
55
*.so
6-
.Python
7-
build/
8-
develop-eggs/
9-
dist/
10-
downloads/
11-
eggs/
12-
.eggs/
13-
lib/
14-
lib64/
15-
parts/
16-
sdist/
17-
var/
18-
wheels/
19-
*.egg-info/
20-
.installed.cfg
21-
*.egg
22-
23-
# Virtual Environment
246
venv/
25-
ENV/
26-
env/
277
.venv/
8+
*.egg-info/
289

29-
# IDE
30-
.idea/
31-
.vscode/
32-
*.swp
33-
*.swo
34-
*~
10+
# Node.js
11+
node_modules/
12+
build/
13+
.docusaurus/
14+
.cache-loader/
3515

36-
# Environment variables
16+
# Environment
3717
.env
3818
.env.local
39-
.env.*.local
4019

41-
# Output files
20+
# Output
4221
output/
43-
*.log
22+
23+
# IDE
24+
.idea/
25+
.vscode/
26+
*.swp
4427

4528
# OS
4629
.DS_Store
4730
Thumbs.db
4831

49-
# Test
50-
.pytest_cache/
51-
.coverage
52-
htmlcov/
32+
# Logs
33+
*.log
34+
npm-debug.log*

0 commit comments

Comments
 (0)