-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (113 loc) · 4.21 KB
/
Copy pathdaily_report.yml
File metadata and controls
133 lines (113 loc) · 4.21 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Daily Report & Deploy
on:
schedule:
- cron: '0 0 * * *' # 每天 UTC 00:00
workflow_dispatch:
push:
branches: [main]
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
env:
PYTHON_VERSION: '3.11'
NODE_VERSION: '20'
jobs:
# Job 1: 生成报告(仅定时或手动触发)
generate-report:
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 📅 Get date
id: date
run: |
echo "date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT
echo "year=$(date +%Y)" >> $GITHUB_OUTPUT
echo "month=$(date +%m)" >> $GITHUB_OUTPUT
- name: 🐍 Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: 📦 Install Python dependencies
run: pip install -r requirements.txt
- name: 🚀 Generate report
env:
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}
LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }}
LLM_MODEL: ${{ secrets.LLM_MODEL }}
GITHUB_API_TOKEN: ${{ secrets.GITHUB_API_TOKEN }}
run: python main.py --local --no-push
- name: 📁 Move output to reports
run: |
DATE=${{ steps.date.outputs.date }}
YEAR=${{ steps.date.outputs.year }}
MONTH=${{ steps.date.outputs.month }}
mkdir -p reports/$YEAR/$MONTH data/$YEAR/$MONTH
cp output/$DATE.md reports/$YEAR/$MONTH/ 2>/dev/null || true
cp output/$DATE.json data/$YEAR/$MONTH/ 2>/dev/null || true
- name: 📤 Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add reports/ data/
git diff --staged --quiet || git commit -m "📈 Add report for ${{ steps.date.outputs.date }}"
git push
- name: 📧 Send email notification
if: success()
uses: dawidd6/action-send-mail@v3
with:
server_address: ${{ secrets.MAIL_SERVER }}
server_port: ${{ secrets.MAIL_PORT }}
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
subject: "📈 GitHub Trending 日报 - ${{ steps.date.outputs.date }}"
to: ${{ secrets.MAIL_TO }}
from: GitHub Trending Reporter
html_body: |
<h1>📈 GitHub Trending 日报 - ${{ steps.date.outputs.date }}</h1>
<p>今日报告已生成,点击下方链接查看完整内容:</p>
<p><a href="https://wayyoungboy.github.io/github-trending-reporter/reports/${{ steps.date.outputs.year }}/${{ steps.date.outputs.month }}/${{ steps.date.outputs.date }}">📊 查看在线报告</a></p>
<hr>
<p><small>此邮件由 GitHub Trending Reporter 自动发送</small></p>
attachments: output/${{ steps.date.outputs.date }}.md
# Job 2: 构建部署网站
build-deploy:
runs-on: ubuntu-latest
needs: [generate-report]
if: always() && (needs.generate-report.result == 'success' || needs.generate-report.result == 'skipped')
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: 🔄 Pull latest changes
run: git pull origin main
- name: 🟢 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 📦 Install dependencies
run: npm install
- name: 🔧 Generate sidebar
run: npm run generate-sidebar
- name: 🏗️ Build
run: npm run build
- name: 📤 Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: build
# Job 3: 部署到 GitHub Pages
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build-deploy
steps:
- name: 🚀 Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4