Run conversion.py and upload file #6
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 | |
run: python conversion.py | |
# 创建一个 Git 标签和 Release | |
# - name: Create Release | |
# id: create_release | |
# uses: actions/create-release@v1 | |
# with: | |
# tag_name: v1.0.${{ github.run_number }} # 根据运行次数动态生成标签 | |
# release_name: "Release v1.0.${{ github.run_number }}" | |
# draft: false | |
# prerelease: false | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# 创建一个 Git 标签 | |
- name: Create Git tag | |
run: | | |
TAG_NAME=v1.0.${{ github.run_number }} | |
git config --local user.name "github-actions" | |
git config --local user.email "[email protected]" | |
git tag $TAG_NAME | |
git push origin $TAG_NAME | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# 上传生成的文件到 GitHub Release | |
- name: Upload to GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: output.yaml # 生成文件路径 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |