gitlab/github 的 CI/CD 这个功能可以保存文件到 git 仓库吗,比如上传 markdown 文件,自动执行程序解析成 html 文件,然后还是保存在这个仓库里

2022-03-09 17:33:28 +08:00
 zxCoder
1068 次点击
所在节点    问与答
5 条回复
learningman
2022-03-09 17:45:34 +08:00
可以,github actions
Rwing
2022-03-09 18:01:15 +08:00
0o0O0o0O0o
2022-03-09 18:06:58 +08:00
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com

然后 push 就行

或者用 github api ,repos.createOrUpdateFileContents ,本仓库不需要申请 PAT ,会自动分配一个 github.token
swulling
2022-03-09 18:18:51 +08:00
会,但是别放到同一个分支下,那就成死循环了。

一般是 main 分支放 markdown ,然后 action 发布到 gh-pages 分支。
shadows
2022-03-09 19:55:34 +08:00
@swulling 用 workflow 自动生成的 GITHUB_TOKEN 不会死循环:

https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow

When you use the repository's GITHUB_TOKEN to perform tasks, events triggered by the GITHUB_TOKEN will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs. For example, if a workflow run pushes code using the repository's GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/839190

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX