更新数据集并同步至huggingface #104
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: 更新数据集并同步至huggingface | |
| 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 }} | |
| - name: 同步到 Hugging Face Space (可选) | |
| if: env.HF_TOKEN != '' | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| set -e | |
| sudo apt-get update && sudo apt-get install -y rsync | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| git clone https://huggingface.co/spaces/Viper3733/LOL-DeepWinPredictor hf_repo | |
| rsync -av --delete --exclude='.git' --exclude='hf_repo' ./ hf_repo/ | |
| cd hf_repo | |
| git add . | |
| git diff --cached --quiet || git commit -m "数据自动更新 (来自 GitHub Actions)" | |
| git push https://user:$HF_TOKEN@huggingface.co/spaces/Viper3733/LOL-DeepWinPredictor main |