Add pipeline to automatically update flakes

This commit is contained in:
Ciapa 2023-04-16 19:48:51 +00:00
parent 79dcbb7327
commit 138976df16
1 changed files with 32 additions and 0 deletions

View File

@ -20,6 +20,9 @@ test:
stage: test stage: test
script: script:
- nix flake check - nix flake check
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
deploy: deploy:
stage: deploy stage: deploy
@ -32,4 +35,33 @@ deploy:
# Deploy everything # Deploy everything
- nix develop --command deploy - nix develop --command deploy
rules: rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH == "master" - if: $CI_COMMIT_BRANCH == "master"
check updates:
stage: test
script:
# Prepare git access
- nix-env -iA nixos.openssh
- eval "$(ssh-agent -s)"
- chmod 0600 $SSH_UPDATE_KEY
- ssh-add $SSH_UPDATE_KEY
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan git.lewd.wtf >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git config --global user.name "NixOS Flake Update"
- git config --global user.email "git@lewd.wtf"
- git remote rm origin && git remote add origin "git@git.lewd.wtf:${CI_PROJECT_PATH}.git"
# Update flakes
- nix flake update
# Push changes
- git checkout -b flakes_update
- git add .
- git commit -m 'Update NixOS Flakes'
- git push --set-upstream origin flakes_update -o merge_request.create
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"