Run conversion.py and upload file #198
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 conversion.py and upload file | |
on: | |
schedule: | |
- cron: '0 6 * * *' # 每天 UTC 时间 6:00 运行(可根据需求调整) | |
workflow_dispatch: # 支持手动触发 | |
jobs: | |
run_script: | |
runs-on: ubuntu-latest | |
steps: | |
# 检出代码 | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# 设置 Python 环境 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' # 设置需要的 Python 版本,可以指定为具体版本号如 3.9 | |
# 安装所需依赖库 | |
- name: Install dependencies | |
run: | | |
pip install requests pyyaml | |
# 运行 Python 脚本 | |
- name: Run conversion.py | |
env: | |
my_url: ${{ secrets.MY_URL }} | |
run: python conversion.py "$my_url" | |
- name: Commit and push output.yaml | |
run: | | |
git config --local user.name "github-actions" | |
git config --local user.email "[email protected]" | |
git add output.yaml | |
git add simple.yaml | |
if ! git diff --cached --quiet; then | |
git commit -m "Updated Subscriptions" | |
git push | |
else | |
echo "No changes to commit." | |
fi | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 使用 GitHub 提供的 token 进行身份验证 |