python - 使用 github 操作将 python 生成的图提交到 repo
问题描述
我正在尝试创建一个运行 python 脚本(输出三个图表)的 GitHub 工作流,将这些图表添加到 readme.md 然后将更改提交到 repo 并在自述文件页面上显示图表。我想触发新的推动。
作为 bash 脚本,它看起来像这样:
git pull
python analysis_1.py
git add .
git commit -m "triggered on action"
git push
我不确定从哪里开始或如何设置操作。我尝试设置一个,但它不会做出任何改变。
解决方案
有关如何在工作流程期间提交回存储库的信息,请参阅此答案。
在您的情况下,它可能看起来像这样。在必要时对其进行调整。
on:
push:
branches:
- master
jobs:
updateGraphs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Generate graphs
run: python analysis_1.py
- name: Update graphs
run: |
git config --global user.name 'Your Name'
git config --global user.email 'your-username@users.noreply.github.com'
git commit -am "Update graphs"
git push
或者,使用create-pull-request操作提出拉取请求,而不是立即提交。
on:
push:
branches:
- master
jobs:
updateGraphs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Generate graphs
run: python analysis_1.py
- name: Create Pull Request
uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update graphs
title: Update graphs
branch: update-graphs
推荐阅读
- unity3d - Unity 2017.3 构建资产包需要很长时间
- c++ - 可以采用 Eigen::vector 或 std::vector 的 C++ 模板函数
- mysql - Laravel MySQL 搜索。允许用户进行自定义布尔搜索
- c# - Unity 2D - 导致疯狂延迟的程序(字符串代码)
- sql-server - SQL Server 查询每一行
- dependency-injection - Google Guice 每次都返回新实例
- python - 如何在标签中同时显示图片和文字?(PyQt)
- c# - 是否可以通过 `dotnet` CLI 命令将文件添加到项目中?
- javascript - $未定义,js中没有def错误
- android - Appcelerator Titanium 中的自定义通知视图