Gitlab CI 作业应该更改源代码。诗歌动态版本控制
我想运行一项作业,该作业启动诗歌 - 诗歌 - 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。这是可能的。您需要以下步骤
生成ssh键对过程。
ssh -keygen -t ed25519 -c“ gitlab ci的密钥” -f gitlab -ci_ed25519
!请勿在SSH键中添加密码!
这给了您两个文件
gitlab-ci_ed25519.pub
和gitlab-ci_ed25519
创建一个部署密钥使用您的存储库的写入访问(也可能在组级别上)。使用步骤1的公共密钥:
gitlab-ci_ed25519.pub
。可以在
/settings/repository
下找到部署密钥部分
- /settings/repository
受保护的分支。对于您的用例,可能有必要允许部署钥匙推向受保护的分支。
可以在
/settings/repository
下找到受保护的分支机构
- /settings/repository
创建一个变量
ssh_private_key
带有从步骤1开始的私钥:gitlab-ci_ed25519
。可以在
- /settings/ci_cd
下找到变量部分
注释:您可以通过将其设置为“受保护”来为
ssh_private_key
变量添加一些安全性。如果选择,则该变量仅在受保护分支或标签上运行的管道中可用。可以找到有关安全的更多信息在这里。并创建
.gitlab-ci.yml
使用部署密钥访问存储库。Rule
指令以控制何时开始作业并防止无尽的循环。Yes. This is possible. You need the following steps
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
andgitlab-ci_ed25519
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
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
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.Follow this guide and create a
.gitlab-ci.yml
that uses the deploy key to access the repo.rule
directive to control when to start the job and to prevent an endless loop.