Run Python script and update image #343
This file contains 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: Run Python script and update image | |
on: | |
schedule: | |
- cron: '0 3 * * *' # 每天凌晨3点运行 | |
push: | |
branches: | |
- main # 或者你想要运行这个工作流的分支 | |
jobs: | |
run-script: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Install fonts | |
run: | | |
mkdir -p ~/.fonts | |
cp fonts/* ~/.fonts/ | |
fc-cache -f -v | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests matplotlib pandas mplcyberpunk | |
- name: Run script | |
run: | | |
python ./source/main.py # 替换为你的Python脚本文件名 | |
tree -a | |
- name: Commit and push if it changed | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add . | |
git diff --quiet && git diff --staged --quiet || git commit -m "Update image" | |
git push -f origin main |