mirror of
https://gitee.com/houhuan/TrendRadar.git
synced 2025-12-21 16:17:17 +08:00
49 lines
1.2 KiB
YAML
49 lines
1.2 KiB
YAML
name: Hot News Crawler
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '*/50 * * * *' # 每50分钟运行一次
|
|
workflow_dispatch:
|
|
|
|
# 添加权限设置
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
crawl:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.9'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install requests pytz
|
|
|
|
- name: Create frequency_words.txt if not exists
|
|
run: |
|
|
if [ ! -f frequency_words.txt ]; then
|
|
echo "Creating empty frequency_words.txt file"
|
|
touch frequency_words.txt
|
|
fi
|
|
|
|
- name: Run crawler
|
|
env:
|
|
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}
|
|
GITHUB_ACTIONS: true
|
|
run: python main.py
|
|
|
|
- name: Commit and push if changes
|
|
run: |
|
|
git config --global user.name 'GitHub Actions'
|
|
git config --global user.email 'actions@github.com'
|
|
git add -A
|
|
git diff --quiet && git diff --staged --quiet || (git commit -m "Auto update by GitHub Actions at $(TZ=Asia/Shanghai date)" && git push)
|