更新数据集 #93
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 更新数据集 | |
on: | |
schedule: | |
- cron: '0 0 * * 0' # 每周日 0点运行 | |
workflow_dispatch: | |
jobs: | |
run-main: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 设置 Python 环境 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: 安装依赖 | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: 运行 main.py | |
env: | |
MYSQL_HOST: ${{ secrets.MYSQL_HOST }} | |
MYSQL_PORT: ${{ secrets.MYSQL_PORT }} | |
MYSQL_USER: ${{ secrets.MYSQL_USER }} | |
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} | |
MYSQL_CHARSET: ${{ secrets.MYSQL_CHARSET }} | |
MYSQL_DATABASE: ${{ secrets.MYSQL_DATABASE }} | |
MONGO_URI: ${{ secrets.MONGO_URI }} | |
PROXY: ${{ secrets.PROXY }} | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
python main.py | |
- name: 配置 Git | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: 检查变更并提交 | |
run: | | |
git add . | |
git diff --cached --quiet || git commit -m "数据自动更新" | |
- name: 推送变更 | |
run: | | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git | |
git push origin main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |