2023-07-11 11:34:08 +02:00
default :
image : nixos/nix:2.16.1
stages :
- update_flake_lock
- apply
- commit_flake
update_flake_lock :
stage : update_flake_lock
2023-08-07 22:24:43 +02:00
rules :
- if : $RUN_JOB == "update_flake_lock"
2023-07-11 11:34:08 +02:00
script :
- nix flake update --extra-experimental-features nix-command --extra-experimental-features flakes
2023-07-13 21:42:08 +02:00
artifacts :
paths :
- ./flake.lock
2023-07-11 11:34:08 +02:00
apply :
stage : apply
2023-08-07 22:24:43 +02:00
rules :
- if : $RUN_JOB == "deploy"
2023-07-11 11:34:08 +02:00
script :
- nix-env --install colmena
2023-07-13 20:56:30 +02:00
- eval $(ssh-agent -s)
- chmod 600 "$SSH_PRIVATE_KEY"
- ssh-add "$SSH_PRIVATE_KEY"
- git clone https://oauth2:${ACCESS_TOKEN_KNOWN_HOSTS}@git.grzb.de/yuri/known_hosts.git /root/.ssh
2023-07-13 21:42:08 +02:00
- colmena build
2023-07-13 00:28:22 +02:00
- colmena apply --no-keys
2023-07-13 21:42:08 +02:00
artifacts :
paths :
- ./flake.lock
2023-07-11 11:34:08 +02:00
commit_flake :
stage : commit_flake
2023-08-07 22:24:43 +02:00
rules :
- if : $RUN_JOB == "update_flake_lock"
2023-07-13 20:56:30 +02:00
variables :
GIT_AUTHOR_EMAIL : $GIT_AUTHOR_EMAIL
GIT_AUTHOR_NAME : $GIT_AUTHOR_NAME
GIT_COMMITTER_EMAIL : $GIT_COMMITTER_EMAIL
GIT_COMMITTER_NAME : $GIT_COMMITTER_NAME
ACCESS_TOKEN : $ACCESS_TOKEN
2023-07-11 11:34:08 +02:00
script :
2023-07-13 21:42:08 +02:00
- git commit -m "Update flake.lock file" -m "Triggered by scheduled pipeline $CI_PIPELINE_ID at $CI_PIPELINE_CREATED_AT." || failure_code=$?
- if [ "$failure_code" == "" ]; then git push https://gitlab-runner-server:${ACCESS_TOKEN}@${CI_SERVER_HOST}/yuri/nix-infra.git HEAD:$CI_COMMIT_BRANCH; fi