Skip to content

Daily Sentiment Analysis #29

Daily Sentiment Analysis

Daily Sentiment Analysis #29

Workflow file for this run

name: Daily Sentiment Analysis
on:
schedule:
# 北京时间每天 00:30(0 点后)= UTC 16:30
# 抓取前一自然日全天帖子,TuShare 取该日或之前最近已入库交易日行情
- cron: "30 16 * * *"
workflow_dispatch:
inputs:
target_day:
description: 分析哪一天(北京时间)
required: true
default: today
type: choice
options:
- today
- yesterday
permissions:
contents: write
jobs:
analyze:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
cache-dependency-path: requirements.txt
- name: Prepare config
run: cp config.example.json config.json
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run daily sentiment analysis (Beijing time)
env:
TZ: Asia/Shanghai
TUSHARE_TOKEN: ${{ secrets.TUSHARE_TOKEN }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
DAY="${{ inputs.target_day }}"
else
DAY="yesterday"
fi
echo "Running: python main.py --${DAY} --no-browser"
python main.py "--${DAY}" --no-browser
- name: Commit results
env:
TZ: Asia/Shanghai
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -f data.json posts.json index.html
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "chore: daily sentiment $(date +%Y-%m-%d)"
git push
fi