Reputation: 69
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?
Upvotes: 1
Views: 1156
Reputation: 9498
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
and gitlab-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.Upvotes: 1