From abad30d9cf4f040b492ce5ca7313038981b1da1c Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Tue, 7 Sep 2021 20:52:46 +0300 Subject: [PATCH] First trial in a nix flake update CI --- .gitlab-ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..b27da45 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,22 @@ +default: + image: nixpkgs/nix-flakes + +update-nix-flakes: + # Based on: https://forum.gitlab.com/t/git-push-from-inside-a-gitlab-runner/30554/5 + before_script: + - eval `ssh-agent -s` + - mkdir --mode=700 -p ~/.ssh + - ssh-keyscan "$CI_SERVER_HOST" >> ~/.ssh/known_hosts + - echo "$SSH_PUBLIC_KEY" >> ~/.ssh/id_rsa.pub + - echo "${SSH_PRIVATE_KEY}" | ssh-add - + script: + - git config --global user.email "nix-matlab-CI@doronbehar.com" + - git config --global user.name "Nix Matlab CI" + - git remote add ci ssh://git@$CI_SERVER_HOST/$CI_PROJECT_PATH.git + - type nix + - nix --version + - nix flake update + - git add . + - git status + - git commit --message "[skip ci] Automatic nix flake update by CI" || echo "No changes, nothing to commit!" + - git push ci HEAD:$CI_COMMIT_REF_NAME # Pushes to the same branch as the trigger