Files
daily_stock_analysis/.github/workflows/daily_analysis.yml
2026-01-10 15:38:56 +08:00

107 lines
3.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: 每日股票分析
on:
# 定时触发 - 每天北京时间 18:00 (UTC 10:00)
schedule:
- cron: '0 10 * * 1-5' # 周一到周五UTC 10:00 = 北京时间 18:00
# 手动触发
workflow_dispatch:
inputs:
mode:
description: '运行模式'
required: true
default: 'full'
type: choice
options:
- full # 完整分析(股票+大盘)
- market-only # 仅大盘复盘
- stocks-only # 仅股票分析
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置 Python 环境
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: 安装依赖
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: 创建必要目录
run: |
mkdir -p data logs reports
- name: 执行股票分析
env:
# Gemini AI
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
GEMINI_MODEL: ${{ secrets.GEMINI_MODEL || 'gemini-3-flash-preview' }}
GEMINI_MODEL_FALLBACK: ${{ secrets.GEMINI_MODEL_FALLBACK || 'gemini-2.5-flash' }}
GEMINI_REQUEST_DELAY: '3.0' # GitHub Actions 建议增加延时
# 数据源 (可选)
TUSHARE_TOKEN: ${{ secrets.TUSHARE_TOKEN }}
# 搜索服务
TAVILY_API_KEYS: ${{ secrets.TAVILY_API_KEYS }}
SERPAPI_API_KEYS: ${{ secrets.SERPAPI_API_KEYS }}
# 企业微信通知
WECHAT_WEBHOOK_URL: ${{ secrets.WECHAT_WEBHOOK_URL }}
# 自选股列表 (从 secrets 或使用默认值)
STOCK_LIST: ${{ secrets.STOCK_LIST || '600519' }}
# 其他配置
LOG_LEVEL: INFO
DATA_DAYS: 60
MAX_CONCURRENT: 3
run: |
# 判断运行模式
MODE="${{ github.event.inputs.mode || 'full' }}"
echo "=========================================="
echo "运行模式: $MODE"
echo "自选股: $STOCK_LIST"
echo "时间: $(TZ='Asia/Shanghai' date '+%Y-%m-%d %H:%M:%S')"
echo "=========================================="
if [ "$MODE" = "market-only" ]; then
python main.py --market-review
elif [ "$MODE" = "stocks-only" ]; then
python main.py --no-market-review
else
python main.py
fi
- name: 上传分析报告
uses: actions/upload-artifact@v4
if: always()
with:
name: analysis-reports-${{ github.run_number }}
path: |
reports/
logs/
retention-days: 30
- name: 显示运行结果
if: always()
run: |
echo "=========================================="
echo "分析完成"
echo "=========================================="
if [ -d "reports" ]; then
echo "生成的报告:"
ls -la reports/
fi