zxCoder
V2EX  ›  问与答

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

  •  
  •   zxCoder · Mar 9, 2022 · 1487 views
    This topic created in 1555 days ago, the information mentioned may be changed or developed.
    5 replies    2022-03-09 19:55:34 +08:00
    learningman
        1
    learningman  
       Mar 9, 2022 via Android   ❤️ 1
    可以,github actions
    Rwing
        2
    Rwing  
       Mar 9, 2022   ❤️ 1
    0o0O0o0O0o
        3
    0o0O0o0O0o  
       Mar 9, 2022   ❤️ 1
    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
        4
    swulling  
       Mar 9, 2022   ❤️ 1
    会,但是别放到同一个分支下,那就成死循环了。

    一般是 main 分支放 markdown ,然后 action 发布到 gh-pages 分支。
    shadows
        5
    shadows  
       Mar 9, 2022
    @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.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4072 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 05:24 · PVG 13:24 · LAX 22:24 · JFK 01:24
    ♥ Do have faith in what you're doing.