Gitlab CI 作业应该更改源代码。诗歌动态版本控制

发布于 2025-01-19 07:15:43 字数 158 浏览 1 评论 0原文

我想运行一项作业,该作业启动诗歌 - 诗歌 - versioning,然后将新版本添加到pyproject.toml__ init __ init __. py

是否可以使用CI作业更改源代码?

I would like to run a job which launches poetry-dynamic-versioning and add new version to pyproject.toml and __init__.py.

Is it possible to change source code with CI job?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蒗幽 2025-01-26 07:15:43

是的。这是可能的。您需要以下步骤

  1. 生成ssh键对过程。

    ssh -keygen -t ed25519 -c“ gitlab ci的密钥” -f gitlab -ci_ed25519

    !请勿在SSH键中添加密码!

    这给了您两个文件gitlab-ci_ed25519.pubgitlab-ci_ed25519

  2. 创建一个部署密钥使用您的存储库的写入访问(也可能在组级别上)。使用步骤1的公共密钥:gitlab-ci_ed25519.pub

    可以在/settings/repository

    下找到部署密钥部分

  3. 可以在- /settings/repository

    受保护的分支。对于您的用例,可能有必要允许部署钥匙推向受保护的分支。

    可以在/settings/repository

    下找到受保护的分支机构

  4. 可以在- /settings/repository

    创建一个变量 ssh_private_key带有从步骤1开始的私钥:gitlab-ci_ed25519

    可以在- /settings/ci_cd

    下找到变量部分

    注释:您可以通过将其设置为“受保护”来为ssh_private_key变量添加一些安全性。如果选择,则该变量仅在受保护分支或标签上运行的管道中可用。可以找到有关安全的更多信息在这里

  5. 并创建.gitlab-ci.yml使用部署密钥访问存储库。


  • 现在,您的工具(诗歌 - 动态化,git)应该能够修改文件并将其推回您的来源。
  • 可以在此处找到一个类似的示例(对于Docker执行者): Gitlab CI拒绝使用Witr access 使用部署密钥访问(我可以确认它有效)
  1. 作业控制(可选)。由于Gitlab-CI的推动可以再次触发管道,因此您可能需要添加一些Rule指令以控制何时开始作业并防止无尽的循环。

Yes. This is possible. You need the following steps

  1. Generate a ssh key pair for your CI processes.

    ssh-keygen -t ed25519 -C "Key for Gitlab CI" -f gitlab-ci_ed25519

    !Do not add a passphrase to the SSH key!

    This gives you two files gitlab-ci_ed25519.pub and gitlab-ci_ed25519

  2. Create a deploy key with write access for your repo (also possible on group level). Use the public key from step 1 for it: gitlab-ci_ed25519.pub.

    The Deploy Key section can be found under -/settings/repository

  3. Protected Branches. For your use case it may be necessary to allow the deploy key to push to protected branches.

    Protected branches can be found under -/settings/repository

  4. Create a variable SSH_PRIVATE_KEY with the private key from step 1: gitlab-ci_ed25519.

    The variable section can be found under -/settings/ci_cd

    Note: You can add some security to the SSH_PRIVATE_KEY variable by setting it as "protected". If selected, the variable is only available in pipelines that run on protected branches or tags. More info on security can be found here.

  5. Follow this guide and create a .gitlab-ci.yml that uses the deploy key to access the repo.

  1. Job Control (Optional). Since a push from Gitlab-CI can trigger the pipeline again you may want to add some rule directive to control when to start the job and to prevent an endless loop.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文