第一次
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
name: Run Python Script and Push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
run-python-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# 步骤 1: 克隆当前仓库
|
||||
- name: Checkout current repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# 步骤 2: 设置 Python 环境
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.12'
|
||||
|
||||
# 步骤 3: 安装依赖(如果有)
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
|
||||
# 步骤 4: 运行 Python 脚本
|
||||
- name: Run Python script
|
||||
run: |
|
||||
g.py
|
||||
|
||||
# 步骤 5: 克隆目标仓库
|
||||
- name: Checkout target repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: owner/target-repo # 替换为目标仓库的 owner/repo
|
||||
path: target-repo
|
||||
token: ${{ secrets.GITHUB_TOKEN }} # 使用 GitHub Token 进行认证
|
||||
|
||||
# 步骤 6: 将生成的文件复制到目标仓库
|
||||
- name: Copy generated files to target repository
|
||||
run: |
|
||||
cp -r generated_files/ target-repo/ # 替换为你的生成文件路径和目标仓库路径
|
||||
|
||||
# 步骤 7: 提交并推送更改到目标仓库
|
||||
- name: Commit and push changes to target repository
|
||||
run: |
|
||||
cd target-repo
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add .
|
||||
git commit -m "Automated commit by GitHub Actions"
|
||||
git push
|
||||
Reference in New Issue
Block a user