ci: improve the pipelines

This commit is contained in:
silver 2023-08-07 03:03:46 +01:00
parent 5c62e7ede5
commit a55e963a6f

View file

@ -4,6 +4,7 @@ stages:
- flake
- test
- deploy
- deploy_gitlab
# Update the flake for any changes upstream
# Passed in from upstream
@ -39,27 +40,8 @@ update:
variables:
- $UPDATE_FLAKE == "yes"
build:
stage: test
tags:
- nix
before_script:
- . "$HOME/.nix-profile/etc/profile.d/nix.sh"
# use the new flake
- git pull origin main
script:
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- build
only:
changes:
- applications/**/*
- machines/**/*
- secrets/**/*
- flake.*
- .gitlab-ci.yml
# every commit on main will build and deploy
deploy:
stage: deploy
.build_template: &build
tags:
- nix
before_script:
@ -71,11 +53,6 @@ deploy:
# load nix environment
- . "$HOME/.nix-profile/etc/profile.d/nix.sh"
- git pull origin main
script:
# dns is always deployed first
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-dns
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-core
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active
only:
refs:
- main
@ -86,19 +63,38 @@ deploy:
- flake.*
- .gitlab-ci.yml
deploy_gitlab:
build:
<<: *build
stage: test
script:
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- build
# dns always has to be deployed first
deploy_dns:
<<: *build
stage: deploy
tags:
- nix
before_script:
# setup ssh key
- eval $(ssh-agent -s)
- echo "$DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
# load nix environment
- . "$HOME/.nix-profile/etc/profile.d/nix.sh"
- git pull origin main
script:
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-dns
deploy_core:
<<: *build
stage: deploy
needs:
- deploy_dns
script:
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-core
deploy_active:
<<: *build
stage: deploy
needs:
- deploy_dns
script:
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active
deploy_gitlab:
<<: *build
stage: deploy_gitlab
script:
- nix --experimental-features 'nix-command flakes' run nixpkgs#colmena -- apply --on @active-gitlab
when: manual